Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example reconnecting Client sometimes won't reconnect #185

Closed
frankfil opened this issue Mar 22, 2023 · 0 comments · Fixed by #186
Closed

Example reconnecting Client sometimes won't reconnect #185

frankfil opened this issue Mar 22, 2023 · 0 comments · Fixed by #186
Labels
bug Something isn't working

Comments

@frankfil
Copy link

Describe the bug

I have a client written using your Example Client Test using the reconnection logic in there that I have been testing and hit an issue where it would not reconnect, but would get stuck when trying to create a new Channel on a broken Connection.

This code is the problem:

err := client.init(conn)
if err != nil {
client.logger.Println("Failed to initialize channel. Retrying...")
select {
case <-client.done:
return true
case <-time.After(reInitDelay):
}
continue
}

Reproduction steps

I found this by complete accident.

My app is running on a box that has a wired ethernet connection and a 4G backup. I was testing failing over to the 4G backup by physically pulling the ethernet cable from the box. And then reconnecting to test failing back to wired.

In doing this several times I just happened to hit the right timing where the wired connection was dropped between the connection being created successfully and the channel creation call being made.

I've no idea how you would automate this test!

Expected behavior

Example code that demonstrates reconnection should reconnect 😊

Additional context

This looks like a pretty simple fix, by adding a check of the client.notifyConnClose in that select block, I'll create a PR shortly.

@frankfil frankfil added the bug Something isn't working label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant