EventSource icon indicating copy to clipboard operation
EventSource copied to clipboard

Possible connection leak? A new SSE connection is opened on every onerror status=undefined

Open akaskj opened this issue 5 years ago • 10 comments

Hi @Yaffle need your help in figuring this out. I see a pattern where a new connection is opened on every onerror and the status for the on error is status=undefined. The client does not get any data through SSE connection and after few seconds onerror with status=undefined is invoked again and a new connection is made to the backend. All these connections kept open till the browser/session is closed and all the connections are closed together. Could you please help in figuring this out and understand why this is happening and help in fixing it?

akaskj avatar Feb 03 '20 17:02 akaskj

@akaskj , how to reproduce? In which web browser can this be reproduced?

Yaffle avatar Feb 09 '20 14:02 Yaffle

@akaskj , how to reproduce? In which web browser can this be reproduced?

@Yaffle Unable to reproduce it locally, this is happening in client systems in production. I am trying to put in more logging when an error event is fired and trying to narrow down on a particular scenario.

Had anyone else complained about this? or come across this issue before?

akaskj avatar Feb 09 '20 21:02 akaskj

@akaskj does it happen for all clients? are you using HTTPS ? How should the polyfill behave in case it cannot receive data?

Yaffle avatar Feb 11 '20 08:02 Yaffle

Sorry, missed your reply. It happens only with a subset of clients. Yes we are using HTTPS. The problem is data is sent from the server but polyfill is reporting as it never received the data and triggers onerror and opens new SSE connection.

akaskj avatar Feb 24 '20 17:02 akaskj

I am also getting this problem and only in production. It's weird, we have a DEV/QA/Prod environment and it's only happening in Prod. They are all configured the same.

We get a 'onerror' message with (no communication in 45 seconds) every 45 seconds.

Will look into it more, but I'm not sure why our keepalives aren't helping.

Edit: Every browser

henry-chris avatar May 19 '20 13:05 henry-chris

@henry-chris , could you try a new version? I have added some details to this error message.

Yaffle avatar May 19 '20 19:05 Yaffle

@Yaffle I can, thanks. Sadly, my error was due to a bug in our production deployment where my keep-alives weren't getting through in specific instances. Fixing those has alleviated the triggering of this error message in most cases.

I will try it and cause the error a few times and report back.

henry-chris avatar May 19 '20 19:05 henry-chris

same problem. i print readyState is 0 and error is undefined in ErrorEvent.

Veitor avatar Jun 18 '20 05:06 Veitor

@Veitor , unfortunately, I have no ideas how to fix it, please use other libraries which switch to non-SSE transports

Yaffle avatar Jun 18 '20 07:06 Yaffle

@Yaffle Sorry it's taken me a bit. I see an error message explaining the issue and a call stack. Seems good to me.

Since you say 'Reconnecting' I'm guessing I don't need to re-open the connection manually (which I'm currently doing).

We send a keep-alive every 25 seconds...so I'll have to look into why that isn't being found by the polyfilll as I can confirm it's sent. That seems to be an entirely separate issue from this, though.

henry-chris avatar Jun 19 '20 16:06 henry-chris