Skip to content

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

@dgoadby

Description

@dgoadby

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions