-
Notifications
You must be signed in to change notification settings - Fork 98
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
Disconnect method triggers OnClientError callback with net.ErrClosed error #254
Comments
That version is two years old; please try with |
@MattBrittan Thanks for the info, I have updated the version to |
Thanks. The changes I was thinking of were in
|
I have added comments in Will leave this open for a while in case anyone has any suggestions on a better way of dealing with this (and feels it would be beneficial to do so). |
When the Disconnect method is invoked with a specific reason code, the OnClientError callback is unexpectedly triggered with a net.ErrClosed error, even though the Disconnect operation itself returns nil. This suggests that the disconnection is being incorrectly treated as an error, potentially indicating an issue with how the library handles socket closures on client-initiated disconnects.
To reproduce
Configure the client with callbacks for server disconnections and client errors:
Disconnect the client using the Disconnect method with an administrative action reason code:
Expected behaviour:
The expected behavior is for the client to disconnect without invoking the OnClientError callback, as the disconnection is user-initiated and should not be treated as an error condition.
Software used:
MQTT Broker version: emqx:5.3.2
Client version: github.com/eclipse/paho.golang v0.10.1-0.20220826012857-d63b3b28d25f
Additional context
Currently, I am using a workaround that checks for net.ErrClosed in the OnClientError callback to differentiate between genuine errors and this disconnection handling issue. Here is the temporary code adjustment:
It seems there might be an issue with how the socket closure is managed during the disconnection process, perhaps attempting to close an already closed connection.
The text was updated successfully, but these errors were encountered: