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

Subscriptions are dropped following reconnect #10

Open
basak opened this issue May 10, 2021 · 4 comments
Open

Subscriptions are dropped following reconnect #10

basak opened this issue May 10, 2021 · 4 comments

Comments

@basak
Copy link

basak commented May 10, 2021

Hi,

Thank you for trio-paho-mqtt!

Following the pattern in the README.md example, I did something equivalent to:

async with trio.open_nursery() as nursery:
    sync_client = mqtt.Client()
    client = AsyncClient(sync_client, nursery)
    client.connect(...)
    client.subscribe(topic)
    async for message in client.messages():
        ...

However I seemed to stop receiving messages after a while. I think this is because the connection timed out, the (sync) client reconnected automatically, but the subscription wasn't recreated.

https://github.com/eclipse/paho.mqtt.python/blob/master/README.rst says:

# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))

    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe("$SYS/#")

However I can't straightforwardly do this in trio-paho-mqtt because you're already using the sync client on_connect method for internal purposes, and aren't exposing that to the API user.

I wonder if you could provide on_connect functionality directly from AsyncClient please?

@bkanuka
Copy link
Owner

bkanuka commented May 11, 2021

You are absolutely right that this is a big. Unfortunately I don't have the time to maintain this project anymore. I will update the readme and possibly archive the project. Sorry.

@basak
Copy link
Author

basak commented May 11, 2021 via email

@bkanuka
Copy link
Owner

bkanuka commented May 11, 2021 via email

@basak
Copy link
Author

basak commented May 12, 2021

Thanks! You can just add people to a PyPI project as "collaborators". My username on PyPI is rcab.

I intend to send a pull request for this issue in the next few days.

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