Skip to content

lines 216 and 220 both modify the broker string, thus not allowing reconnect to work #26

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

Closed
bangell opened this issue Apr 9, 2020 · 5 comments

Comments

@bangell
Copy link

bangell commented Apr 9, 2020

proto, dummy, self.broker = self.broker.split("/", 2)

self.broker gets modified during connect, however if you do a reconnect, it tries to parse broker again, however broker was already parsed down (removed the photo, and path). the split fails as broker only contains the host address and there are not enough values to unpack. I would have done a request for pull on this, but didn't know how you wanted to handle this situation.

my broker was set to: http://10.0.0.16

@bangell
Copy link
Author

bangell commented Apr 10, 2020

    try:
        proto, dummy, self.broker, path = self.broker.split("/", 3)
        # replace spaces in path
        path = path.replace(" ", "%20")
    except ValueError:
        proto, dummy, self.broker = self.broker.split("/", 2)
        path = ""

This code in connect will not work when called by reconnect because the broker string gets modified here. It fails in the except routine because broker is just the host address when called for second time so the split fails

@brentru
Copy link
Member

brentru commented Apr 10, 2020

@bangell Since self.broker is only within init and connect, we could handle this by creating a new broker variable and preserving the value of the original self.broker:

proto, dummy, broker, path = self.broker.split("/", 3)
proto, dummy, broker= self.broker.split("/", 2)

@jimbobbennett
Copy link

Hey @bangell - this should be fixed in the latest release. Can you test my fix please and see if it resolves this issue.

@bangell
Copy link
Author

bangell commented Apr 21, 2020 via email

@bangell
Copy link
Author

bangell commented Apr 23, 2020

Thanks, it worked like a champ!

@bangell bangell closed this as completed Apr 24, 2020
rtwfroody pushed a commit to rtwfroody/Adafruit_CircuitPython_MiniMQTT that referenced this issue Sep 18, 2022
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

3 participants