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

If MQTT server disconnects due to duplicate client ID then umqttsimple raises OSERROR(-1) #3

Open
dgoadby opened this issue Dec 19, 2021 · 0 comments

Comments

@dgoadby
Copy link

dgoadby commented Dec 19, 2021

I am running umqttsimple.py with Micropython 1.17 on an ESP32 client. Everything was running perfectly and then, by accident, I used the same MQTT client ID on another device. MQTT responded by disconnecting the original device - it is designed to disconnect the "older" client. I did have a dummy callback in place but was not expecting any topic messages as I had not subscribed to any.

I assume that when MQTT disconnected it created a socket error. The code at line 175 says: "if res == b"": raise OSERROR(-1)". This is the error I got and the main program stopped right there. This may be a socket handling error elsewhere but, in order to make the code more robust I changed the logic to "if res is None or res == b"": return None"

This patch works. Even if the code is not going to be patched, I hope that, by raising the issue, others will see what is happening when it happens to them.

Maybe the real problem is with the socket code which should return "none" when disconnected?

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

1 participant