Category : server-sent-events

Im using server sent events in php. Here is my code in php. <?php header("Cache-Control: no-cache"); header("Content-Type: text/event-stream"); $lastMod = 0; $filename = "tmp.txt"; $filetext = ”; while (true) { $time = filemtime("tmp.txt"); if($time != $lastMod){ $lastMod = $time; $file = fopen($filename, "r"); if ($file == false) { echo ("Error in opening file"); exit(); } ..

Read more

I’ve been working on a stand alone test case for server sent events with PHP and JavaScript. For some reason the required mime text/event-stream that I explicitly set is somehow lost: Chrome: post-processing.php:1 EventSource’s response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection. The mime is set. The stream starts with ..

Read more

I’m trying to stream my text outputs using StreamedResponse in Laravel, but my javascript is not fetching any messages… To make the code shorter, I simplified my situation to this. First I have some named route: Route::any(‘sync-database’,’[email protected]’)->name(‘sync.database’); Then I have the syncDatabase() method in my controller, which is valid and throws no errors: public static ..

Read more

I am trying to code a front end solution to reconnect to a stream, while informing the user of the re connection time etc. Since I do not have access to the server, I am making a small php script to simulate what I would like to achieve. <?php date_default_timezone_set("America/New_York"); header("Cache-Control: no-cache"); header("Content-Type: text/event-stream"); $stream ..

Read more

I am using SSE to push data all day without interrupting but after about 241 seconds my connection interrupts and google chrome creates a new connection with a new request. its while the firefox browser blocks the transfer after this 241 seconds without reconnecting. I changed cash to no-cash and even I changed the PHP ..

Read more