nickvanw / ircx

Basic callback-driven Go IRC bot
Apache License 2.0
37 stars 13 forks source link

Disconnects on read error #19

Closed mvdan closed 8 years ago

mvdan commented 9 years ago

Before the logs were removed, it showed this before dying:

2015/08/21 02:37:28 Error: read tcp 193.219.128.49:6667: i/o timeout

Now it just dies, as expected.

This is when connected to freenode. This is when using HandleLoop like in the example code.

I suggest one of two options:

for {
    err := b.HandleLoop()
    log.Printf("HandleLoop exited: %v", err)
}

(assuming no reconnect is required)

nickvanw commented 9 years ago

Hi @mvdan

Upon disconnection, ReadLoop will attempt to reconnect if it's configured to: https://github.com/nickvanw/ircx/blob/master/bot.go#L116

By setting the MaxRetries to anything above 0, it will automatically reconnect when there is a read error.

I think adding an error return to HandleLoop may be a good additional step, thoughts?

mvdan commented 9 years ago

I see, hadn't noticed you could configure MaxRetries. That works for me, as I don't need a stricter control over disconnects and retries.

Sure, HandleLoop could return an error.

mvdan commented 8 years ago

So I wasn't closing this issue because I was getting send errors after a reconnet.

Reason: I'm an idiot. This was happening because I had a pointer to Sender, not to Bot. So on Reconnect(), when it called Connect() again, it would create a new Sender. I would get stuck with the old sender, which had a disonnected tcp connection.