Yaffle / EventSource

a polyfill for http://www.w3.org/TR/eventsource/
MIT License
2.11k stars 338 forks source link

Question : How do you deal with server stop/start #197

Open dngconsulting opened 2 years ago

dngconsulting commented 2 years ago

Hi,

First, thanks for this wonderful polyfill. Works the right way. I have a question regarding the way it deals with servers start/stop. Sometimes, we need to stop and start our server. Relying to heartBeat is too overkill for us as it will reconnect continuously (we don't send events all the times) to the server. When the server is stopped, the XHR Socket status looks active whereas the server is down. Aren't there any way to detect that the XHR socket is broken and raise a specific error ?

Thanks

Sami

Yaffle commented 2 years ago

Hi, thanks! hm... TCP connection close packet signals the other end that the connection is closing, not sure what is going on with your case. May be you are killing the server or break the connection somehow, without "heartbeat" those cases will be detect by TCP keeaplive probes (if the web browser uses them, and some browsers do it, it may take 1minute or more) But in normal cases it should work. Why doesn't it work for you?