EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection.
Why I'm getting this error when sending a request from javascript to servlet?
You need to set the header of the message before sending it:
  response.writeHead(200, {
    'Content-Type': 'text/event-stream',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive'
  });
You can follow this article for more information: https://www.html5rocks.com/en/tutorials/eventsource/basics/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With