fleaz / CptHook

Receive webhooks from different applications and post them to IRC channels
MIT License
17 stars 8 forks source link

Ping/Pong behaviour #44

Closed mweinelt closed 5 years ago

mweinelt commented 5 years ago

Usually its the server that pings the client, and as long as the client answers with a pong everything is fine.

Now when the server goes away CptHook does not seem to take notice. CptHook needs to regularly check whether ping/pongs are happening to detect connection issues. If the server doesn't send any, send them yourself. If that fails multiple times it's time to reconnect.

fleaz commented 5 years ago

I checked the girc documentation and verified with debug logging: A PING is send every 20 seconds and after 3 unanswered requests the client turns into disconnected state and attempts a reconnect. This can be seen in the following log where I dropped my default route to simulate network outage:

debug:01:05:14 conn.go:457: > PING 1556060714342450219
debug:01:05:34 conn.go:457: > PING 1556060734342429672
debug:01:05:54 conn.go:558: closing pingLoop
debug:01:05:54 conn.go:319: received error, beginning clean up
debug:01:05:54 conn.go:491: closing sendLoop
debug:01:05:54 client.go:316: received signal to close, flushing 0 events and executing
debug:01:05:54 client.go:328: closing execLoop
debug:01:05:54 conn.go:371: closing readLoop
debug:01:05:54 conn.go:335: waiting for all routines to finish
WARN[0080] Connection to irc.hackint.eu:6697 terminated: timed out waiting for a requested PING response 
WARN[0080] Reconnecting in 30 seconds...