I have a very simple PHP Server Side Events controller (simplified for this question):
$response = new StreamedResponse(function() {
while (true) {
if(connection_status() != CONNECTION_NORMAL) {
die();
};
echo 'data: '. "\n\n";
ob_end_flush();
flush();
sleep(1);
}
});
$response->headers->set('Cache-Control', 'no-cache');
$response->headers->set('Content-Type', 'text/event-stream');
return $response;
When I call that from my Angular app it opens and closes the connection for every loop, so it looks like this:
Something has changed because previously I just saw one request and a spinning icon for that request and then the data stream would update every second.
What could cause this?