fleaz / CptHook

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

Reconnect after disconnect #6

Closed mweinelt closed 5 years ago

mweinelt commented 6 years ago

Especially after netsplits the bot will not reconnect.

fleaz commented 5 years ago

This was maybe fixed in a0c3653a42d1b7701734597eeb5e403978bdd408 but needs some testing

fleaz commented 5 years ago

I just tested this. When there is no PING from the Server this is catched correctly by your code and he reconnects after 30s and everything is fine.

But when there is an incoming message during the 30s cooldown, i just crashed horibly with a memory violation

2018/08/15 22:09:11 Connection to irc.hackint.eu:6667 terminated: timed out waiting for a requested PING response
2018/08/15 22:09:11 Reconnecting to irc.hackint.eu:6667 in 30 seconds...
Took IRC event out of channel.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7c03ff]

goroutine 18 [running]:
github.com/lrstanley/girc.(*ircConn).rate(0x0, 0x15, 0x0)
    /home/fleaz/workspace/go/src/github.com/lrstanley/girc/conn.go:411 +0x2f
github.com/lrstanley/girc.(*Client).Send(0xc42018e000, 0xc420310770)
    /home/fleaz/workspace/go/src/github.com/lrstanley/girc/conn.go:389 +0x17d
github.com/lrstanley/girc.(*Commands).Message(0xc42017a030, 0xc420024a24, 0x6, 0xc4203331c0, 0x5)
    /home/fleaz/workspace/go/src/github.com/lrstanley/girc/commands.go:108 +0xf5
main.channelReceiver()
    /home/fleaz/workspace/go/src/github.com/f-breidenstein/CptHook/irc.go:106 +0xe8
created by main.ircConnection
    /home/fleaz/workspace/go/src/github.com/f-breidenstein/CptHook/irc.go:87 +0x339

Not sure if this is our fault or a bug in girc. Will investigate this further in the comming days

mweinelt commented 5 years ago

Did you try adding the else/return tree, it was in the girc example.

fleaz commented 5 years ago

I just reported this behaviour upstream: https://github.com/lrstanley/girc/issues/14

mweinelt commented 5 years ago

Just got bitten again:

Sep 08 07:15:43 elsa CptHook[9183]: 2018/09/08 07:15:43 Got http event for /prometheus
Sep 08 07:15:43 elsa CptHook[9183]: Took IRC event out of channel.
Sep 08 09:02:13 elsa CptHook[9183]: 2018/09/08 09:02:13 Got http event for /prometheus
Sep 08 09:02:13 elsa CptHook[9183]: Took IRC event out of channel.
Sep 08 09:02:35 elsa CptHook[9183]: 2018/09/08 09:02:35 Got http event for /prometheus
Sep 08 09:02:35 elsa CptHook[9183]: Took IRC event out of channel.
Sep 08 09:03:45 elsa CptHook[9183]: 2018/09/08 09:03:45 An error occurred while attempting to connect to irc.hackint.eu:6697: timed out waiting for a requested PING response
Sep 08 09:03:45 elsa systemd[1]: cpthook.service: Main process exited, code=exited, status=1/FAILURE
Sep 08 09:03:45 elsa systemd[1]: cpthook.service: Unit entered failed state.
Sep 08 09:03:45 elsa systemd[1]: cpthook.service: Failed with result 'exit-code'.
fleaz commented 5 years ago

@mweinelt The fact that you have the line "An error occurred while attempting to connect to.." in your stacktrace shows that you are not running the fixed version! Compare this output to the diff of commit a0c3653a42d1b7701734597eeb5e403978bdd408