Yaffle / EventSource

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

Why it creates new connections? #164

Closed BonBonSlick closed 3 years ago

BonBonSlick commented 3 years ago
eventsource.js:913 Error: No activity within 45000 milliseconds. 2 chars received. Reconnecting.
    at onTimeout (eventsource.js:936)
    at eventsource.js:945

It is not pinging urls but resubscribes to event streams every 20-90 seconds. This is insane load.| https://github.com/Yaffle/EventSource/issues/163 We have no loops nor intervals, resubscribe is called from this lib loop.

Should be something to disable or extend ping, resubscribe URLs every 45 seconds. Otherwise it may down server right after pushing code to prod.

BonBonSlick commented 3 years ago
    let mercureToken = 'Bearer ' + Cookies.get("mercureAuthorization");
     const event = new EventSourcePolyfill(
        url,
        {
            heartbeatTimeout: 3600*1000,
            headers: {
              'Authorization': mercureToken,
          },
        },
    );