SlackAPI icon indicating copy to clipboard operation
SlackAPI copied to clipboard

Disconnecting after 2 minutes

Open teajaysee opened this issue 5 years ago • 6 comments

I have used this for a long time and used to work fine but now I find I am disconnected after about 2 minutes every time. I am pinging every 3s and getting a pong response. Using the Client.ErrorReceiving method I get this on point of disconnection. ex = {"The remote party closed the WebSocket connection without completing the close handshake."} Have Slack changed something and is there a workaround? Thanks

teajaysee avatar Apr 14 '20 14:04 teajaysee

I have the same issue. I have noticed that the connection fails consistently after exactly 100 seconds, with the same error message as you described. This error started on the 12th of april, at first intermittently and since yesterday every 100 seconds.

I have tried to change the KeepAlive property to 3 seconds, and have tried calling SendPing at 3, 5 and 30 second intervals, but it does not appear to make a difference.

Right now I just reconnect every time, but I’m not sure how to fix it properly.

dalruby avatar Apr 15 '20 15:04 dalruby

I think I have traced this down to a bug detailed in this article: https://stackoverflow.com/questions/40502921/net-websockets-forcibly-closed-despite-keep-alive-and-activity-on-the-connectio

There is a workaround but there will need to be a more permanent fix.

Best regards

Ian

iclaxton avatar Apr 16 '20 14:04 iclaxton

@IanLeeClaxton

From the sound of it, there is activity as the initial post says that they are sending pings every 3s. The issue that stackoverflow is describing is with no traffic at all, so it wouldn't apply here.

@jedidiah81 , I'm not aware of any new requirements Slack may be needing to keep the socket open. I recommend looking at other RTC libraries and see if they have similar issues, as this sounds like either a network problem or an issue from Slack's side.

I'm going to leave this open for now and would like to know what happens, if anything I'm inclined to believe that this could be a product of Slack suddenly receiving a ton of new traffic.

Inumedia avatar Apr 17 '20 13:04 Inumedia

@Inumedia, I was getting the same issue and also sending pings. It seems the ServicePointManager starts a timer and closes a connection after 100 seconds.

Setting the System.Net.ServicePointManager.MaxServicePointIdleTime = int.MaxValue; fixed the issue for me.

Ian

iclaxton avatar Apr 17 '20 14:04 iclaxton

Setting the System.Net.ServicePointManager.MaxServicePointIdleTime = int.MaxValue; fixed the issue for me.

This fixed the issue for me as well, thank you!

It does make me wonder why this problem started popping up all of a sudden.

dalruby avatar Apr 17 '20 14:04 dalruby

@dalruby I'm guessing the possibilities are: a bug in the .net 4.8 websocket class, a recent MS patch or the slack API has started to send a zero content response which is exposing the bug.

I haven't had a chance to investigate but something happened in the last week or so.

iclaxton avatar Apr 17 '20 14:04 iclaxton