Improve handling of connection issues 1/ #61
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem in the automatic reconnect loop: If the connection to the IRC server is dropped it will not be reestablished because the call to
client.Server()
blocks forever. This is fixed by not calling it at this point. But there are other issues we have to tackle.The first one is our locking. We still have a big issue here if the following happens:
client.Connect()
returns an errorclientLock.Lock()
client.Connect()
again and it fails again because our Internet is still brokenCptHook/irc.go
Lines 121 to 129 in 4d1839a
If we want to rewrite the lock logic, we have to think about two scenarios:
How do we handle the time between irc-connection-is-down and the-library-knows-that-the-connection-is-down?
The library sends continuously a PING (every 20 seconds is the smallest time interval we can use). If now() - time_last(PONG) is > 60 seconds, the connection goes in state disconnected. Then
Connect()
returns and we reconnect.What happens if the connection to the IRC server is down, but our http server works and is used? We can