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

Async_client cannot reconnect after network is restored #521

Open
rty813 opened this issue Nov 13, 2024 · 0 comments
Open

Async_client cannot reconnect after network is restored #521

rty813 opened this issue Nov 13, 2024 · 0 comments

Comments

@rty813
Copy link

rty813 commented Nov 13, 2024

I used async_client and turned off automatic reconnect. After successfully establishing a connection, I disconnected from the network. At this time, calling publish would time out. So I actively called client.reconnect()->wait(). Before the connection_lost callback was triggered, I restored the network. At this time, reconnect would be blocked forever although the connection had been restored.

The process is as follows:

  1. connect to broker and publish messages
  2. Disconnect from the network
  3. call client.reconnect()->wait()
  4. restore network before connection_lost callback triggered.
  5. reconnect would be blocked forever.

Additional explanation:
Why do I call reconnect before connection_lost is triggered?
This involves another question. I found that there is a possibility that the connection is disconnected after the system switches the default gateway, but the connection_lost callback is not triggered. Therefore, I added a judgment when sending a message. If the sending of the qos=2 message times out, it is considered that the connection is disconnected and a reconnection is actively called.

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