ysbaddaden / sinapse

Push service for Ruby using EventSource
MIT License
4 stars 1 forks source link

Chunked is discouraged by the protocol documentation #13

Open rewritten opened 10 years ago

rewritten commented 10 years ago

Citing: http://www.w3.org/TR/2009/WD-eventsource-20091029/#notes

Legacy proxy servers are known to, in certain cases, drop HTTP connections after a short timeout. To protect against such proxy servers, authors can include a comment line (one starting with a ':' character) every 15 seconds or so.

Authors are also cautioned that HTTP chunking can have unexpected negative effects on the reliability of this protocol. Where possible, chunking should be disabled for serving event streams unless the rate of messages is high enough for this not to matter.

So not only chunking is not a solution for the proxies dropping requests, but also it may lead to unexpected dropped connections.

A default one-byte comment every 15s should just be the default keep-live tool, and anything else (like supporting libcurl by sending 16 bytes every 15 seconds or something like that) available by configuration.

ysbaddaden commented 10 years ago

HTTP chunked encoding is not about keeping the connection alive, but to ensure that the message is sent as a whole to the client, not buffered.

I'd like more information about the "unexpected negative effects" than just a warning. I noticed buffering, but I never noticed proxies dropping the connection because of chunking.