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

Multiple socket opened when authentication fails #62

Open
robertsLando opened this issue Sep 13, 2017 · 4 comments
Open

Multiple socket opened when authentication fails #62

robertsLando opened this issue Sep 13, 2017 · 4 comments

Comments

@robertsLando
Copy link

Sockets are not closed if authentication fails, after some tries application stop responding and must be closed. In the image below there are the threads created after 3 failed auth:

immagine

@s4v4g3
Copy link

s4v4g3 commented Oct 4, 2017

I see the same problem & looks like the fix is easy, just add an "else" case in the Connect() method:

if (connack.ReturnCode == MqttMsgConnack.CONN_ACCEPTED)
{
       // ......
}
else
{
      Close();
}

@robertsLando
Copy link
Author

robertsLando commented Oct 4, 2017

@s4v4g3 How can I fix this in my application as I can't edit the library reference code? It would be easy to add at line 602 of MqttClient.cs

else
{
      Close();
}

@s4v4g3
Copy link

s4v4g3 commented Oct 4, 2017

I made a local build of the .NET 4.5 library that you can try out if you like.
https://www.dropbox.com/s/cjk89lyi2s85d00/M2Mqtt.Net.dll?dl=0

@robertsLando
Copy link
Author

robertsLando commented Oct 5, 2017

Thanks very much @s4v4g3! Just downloaded the source code of M2MQTT, added those lines to MqttCLient.cs, recompiled the project to make the dll and added a reference to it in my project. Now sockets are closed correctly if auth goes wrong! I have make a PR (#64)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants