hhxsv5 / php-sse

A simple and efficient library implemented HTML5's server-sent events by PHP, is used to real-time push events from server to client, and easier than Websocket, instead of AJAX request.
MIT License
426 stars 49 forks source link

EventSource's response has a MIME type ("application/json") that is not "text/event-stream". Aborting the connection. #15

Closed dev-afzy closed 3 years ago

dev-afzy commented 4 years ago

Hi, I am getting proper response from when I call the specific route. for example server.php is routed to 'http://127.0.0.1:8000/server' i am getting proper response as you said(but Eventstream still empty this was another issue I found this package). But when i tried to trigger the EventSource in my html file I am getting below error. From where the extra header is coming.

EventSource's response has a MIME type ("application/json") that is not "text/event-stream". Aborting the connection.

Please fix this issue. Thank you

hhxsv5 commented 4 years ago

Please make sure these headers are set.

header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
header('Connection: keep-alive');
header('X-Accel-Buffering: no');