Server Sent Events

Has anyone been able to get server-sent events to work. Using the Webkit (Chromium) engine I am able to get the php to post, however, it has to finnish and flush does not work. If I change to Trident engine it fails eventhough I have IE9 installed.

Any comments or direction is appreciated.

/Hakan
My server side is simply:

<?php header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); while (@$i++ < 10){ echo "data: foo|".time()."|more data |"."\n\n".PHP_EOL; @ob_flush(); flush(); // this alarms thus the @ sleep(1); } ?>

and my client side is:

JUST A SECOND, UPDATING DATA

The problem may come from the header(‘Content-Type: text/event-stream’);
header(‘Cache-Control: no-cache’);
The Trident engine doesn’t handle custom content-types.
I’ll keep your sample on the TODO list and check if we can reproduce the problem and fix it.

Thanks for reviewing. I have tried to use all web engines and I have IE9 installed and as a default.

I can reproduce and Java works, however, the server php has to end for the client to be populated which is not the intention of server sent events.

/Hakan

Any chance you had some time to look at this?

We’re working on it, I’ll contact you if I need further info about the problem.

Hi there, any assessments, initial thoughts, or timetable that can be shared? Easy fix, will take long, error on my side, something that needs change in the program?

Been a few weeks and I am just checking in to see if there are any assessments, initial thoughts, or timetable that can be shared? Easy fix, will take long, error on my side, something that needs change in the program?
/Hakan

While working on your problem, I found the solution:
As of today IE9 doesn’t support EventSource (Server Sent Events). Some workarounds: http://html5doctor.com/server-sent-events/

Yes, in Chromium, EventSource works but no php’s flush() support.

How about if your Webkit (chromium) engine is used. Should it work then?

Humm, even if one comment out the flush and use your WebKit (Chromium) engine it fails. You have this working? Has anyone out there got Server Sent Events working?

Have you checked the workarounds at http://html5doctor.com/server-sent-events/