Is an EventSource (SSE) supposed to try to reconnect indefinitely?

前端 未结 6 2146
余生分开走
余生分开走 2021-01-30 09:22

I\'m working on a project utilizing Server-Sent-Events and have just run into something interesting: connection loss is handled differently between Chrome and Firefox.

O

6条回答
  •  梦谈多话
    2021-01-30 09:37

    What I've noticed (in Chrome at least) is that when you close your SSE connection using close() function, it won't try to reconnect again.

    var sse = new EventSource("...");
    sse.onerror = function() {
        sse.close();
    };
    

提交回复
热议问题