-
Notifications
You must be signed in to change notification settings - Fork 539
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
Panic on connection lost / reconnecting #488
Comments
Quick AnalysisThe panic is due to the use of the closed channel
So the use of this channel is pretty well contained so the only thing that I can think of that would explain the panic is that
HypothesisThere is an issue here; the situation of calling So what I suspect is happening is:
Does this match what your code is doing? (i.e. are you calling I can see a few options to fix this; my initial thought is to set |
Thank you for the quick response. Yes, I"m calling Connect() again after Disconnect() with I guess one option for me would to simply drop the client after Disconnect() and re-created it with NewClient(). I would prefer to use the same ClientId as to avoid Unsubscribe() and possibly other issues. Do you see any problem with that? |
…connect could trigger another connection attempt. Signed-off-by: Matt Brittan <[email protected]>
I have merged a fix for this - please see if master fixes your issue (
The only thing to watch out for is that this client would not remember the fact that there are subscriptions in place (so data received from the broker may be ignored). Use |
I have it running for 12 hours until now and seems fine, I'll keep you posted if anything changes. |
Closing this because it appears that the fix works. |
A program with many clients (in the thousands), when there is a network error with the broker, sometimes, there's a panic on closing a channel
Sometimes the OnConnectionLost handler is called before panic (but not always, and not every connection lost leads to a panic)
This is happening with v1.3.1 and v1.3.2 that where tested.
Occasionally the program will call
client.IsConnected() && client.Disconnect()
. Is there a concurrency issue with Disconnect()? The program will not call Disconnect() twice, but it might be possible that a network error to occur during Disconnect() and AutoReconnect is set to true. Is there anyway to avoid this?The text was updated successfully, but these errors were encountered: