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

when mqtt server goes offline (host shut off), and comes back online.... #1466

Closed
geetee24 opened this issue Mar 31, 2022 · 6 comments
Closed
Labels

Comments

@geetee24
Copy link

when mqtt server goes offline (host shut off), and comes back online.... this library's reconnect handler does not recover and does not reconnect.

Need example showing how to accomplish this

@doc-han
Copy link

doc-han commented Apr 4, 2022

Can you provide a sample of your connection code?
Note: when reconnectPeriod is set to 0 reconnection is disabled.
reference

@geetee24
Copy link
Author

geetee24 commented Apr 4, 2022 via email

@danbo
Copy link

danbo commented Oct 23, 2022

I think I have the same problem - if server goes away and client keeps trying to publish,

  1. client says error / connection refused
  2. error handler fires - client "ends"
  3. client disconnecting error (below) upon publish more events - no recovery when server is back online
Error: client disconnecting
    at MqttClient._checkDisconnecting (c:\...\node_modules\mqtt\lib\client.js:577:26)
    at MqttClient.publish (c:\...\node_modules\mqtt\lib\client.js:617:12)
    ...

All examples show using client.end() in the error handler.

mqttClient.on('error', function (err) {
    console.log(err);
    client.end();
  });

When I remove client.end(), the client library reconnects successfully when the server back and continues to send messages as expected. Other clients listening successfully reconnect on their own and receive messages.

I think it's related to this open issue: #1284

Also, can someone clarify why/when we would want to call end() ?

This is against the eclipse mqtt broker.

@robertsLando
Copy link
Member

MQTT 5.0.0 BETA is now available! Try it out and give us feedback: npm i mqtt@beta. It may fix your issues

Copy link

This is an automated message to let you know that this issue has
gone 365 days without any activity. In order to ensure that we work
on issues that still matter, this issue will be closed in 14 days.

If this issue is still important, you can simply comment with a
"bump" to keep it open.

Thank you for your contribution.

@github-actions github-actions bot added the stale label Jul 21, 2024
Copy link

github-actions bot commented Aug 4, 2024

This issue was automatically closed due to inactivity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants