irc icon indicating copy to clipboard operation
irc copied to clipboard

Disconnect issue

Open zdebel opened this issue 4 years ago • 1 comments

I can't seem to figure out how should I handle a disconnect case, my bot keeps disconnecting from time to time (either the irc network issue, or something on my end), the on_disconnect event doesn't get fired. Much obliged for a snippet.

zdebel avatar Apr 23 '21 21:04 zdebel

There are lots of conditions that can lead to disconnects (other than explicit client disconnect):

  • Server disconnects the client.
  • Client disconnects from the server (at OS level).
  • Intermediate network connectivity drops (temporarily, such as in outage).
  • Some intermediate network node drops the connection (blocked traffic, explicit disconnect).

The causes for these are varied, and it can be difficult to ascertain what conditions led to a disconnect or what node initiated the disconnect.

At a basic level, it's important to (a) send periodic keep-alive messages (pings), as servers may disconnect a client they believe to be idle, and (b) respond to keep-alive messages from the server.

If you're doing both of these, the best advice I can give is to inspect the client and attempt to elicit more detail about when the disconnects happen and why. Start with: how do you know your client is disconnected? Can you tell when the disconnection happened?

jaraco avatar May 25 '21 23:05 jaraco