Server-Sent / EventSource implementation Phalcon

I just made an Server-Sent / EventSource implentation for Phalcon. Its slightly hacky since it needs to tear down the output buffering. My hope is that output buffering can be reworked a bit for Phalcon 4 to make EventSource a first class citizen and included in the core. I also hope that people will comment on the design.

PHP

Javascript

edited Jun '17

I am curious after exploring EventSource https://developer.mozilla.org/en-US/docs/Web/API/EventSource it seems to be opening a HTTP connection and keeping it open while listening for text/event-stream type responses.

My concern is that this is going to cause issues with total connection overhead both on the server and client as opposed to websockets for example. Something I pulled from SO: https://stackoverflow.com/a/5326159/666599

SSE suffers from a limitation to the maximum number of open connections, which can be specially painful when opening various tabs as the limit is per browser and set to a very low number (6). The issue has been marked as "Won't fix" in Chrome and Firefox

The advantages are of course it is an existing protocol without the need for a WS server and it has some clever builtins like support for re-connection and event-id

Do you have any resources I can read on the connection overhead say with a standard nginx installation and concurrent users.

I think this is great overall but we should consider what a http to ws hijack would looklike so devs can working with ws without the extra server requirements in phalcon as well.

Also the JS resource has moved it seems https://github.com/perchlayer/webird/blob/master/app/webpack/entries/broadcast/serversent.js



46.9k

Thanks, my links didn't reflect the later changes I made. I wrote a bunch of things about it but the forum ate my post :(.

I personally understand this pain. I am going to be opening a PR to hopefully aleviate some of those pains because I have also had some long posts eaten

Thanks, my links didn't reflect the later changes I made. I wrote a bunch of things about it but the forum ate my post :(.