fluffle/goirc — Issue #9: goirc disconnects (actively) after 5 minutes of inactivity
Author: mstap
Created: 2011-11-15 20:48:45+00:00
State: open

In issue #5, a default timeout of 5 minutes was introduced. The comment stated that there should be a PING within 5 minutes anyway. While it is probably true that most IRC servers are configured with a pingfreq of some value less than 5 minutes, this does not mean that there actually is a PING within 5 minutes:

At least with Unreal3.2.8.1, a ping will be sent after $pingfreq seconds of **inactivity**. I run a goirc bot on a server where pingfreq is 260. When the goirc bot posts a line, the server will register this is activity. Therefore, for 260 seconds, no PING will be sent. However, since this was a write and not a read, and the IRC connection is otherwise absolutely quiet, goirc will eventually run into a timeout, close the connection (the IRC server says "Client exited"), signal the error "irc.recv(): read tcp 127.0.0.1:6667: resource temporarily unavailable" and reconnect (due to my code). I can reliably reproduce this every time.

Therefore, I propose goirc sending a PING request to the server every 250 seconds (or whatever value you think is sufficient) to make the timeout not lead to a disconnect in situations like the one I described above. Unfortunately, I’m not very familiar with neither Go nor goirc’s code structure, otherwise I would have sent a pull request.

Thanks!