EventSource permanent auto reconnection

前端 未结 3 908
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-02 21:36

I am using JavaScript EventSource in my project front-end.

Sometimes, the connection between the browser and the server fails or the server crashes. In these cases,

3条回答
  •  情歌与酒
    2021-01-02 22:04

    In my experience, browsers will usually reconnect if there's a network-level error but not if the server responds with an HTTP error (e.g. status 500).

    Our team made a simple wrapper library to reconnect in all cases: reconnecting-eventsource. Maybe it's helpful.

提交回复
热议问题