-
Notifications
You must be signed in to change notification settings - Fork 1.4k
When the computer enters sleep mode, the MQTT client no longer sends heartbeats. #1761
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
Comments
If that happens means the pc also pauses the worker thread, I think that's an os issue or maybe a setting to save power not an issue with MQTTjs |
I also assumed the same, but a few weeks ago, I was still using the v4.x version of MQTT.js. I specifically wrote a mqtt.worker.js in my local project to handle this issue, and it worked very well, able to maintain the connection all night. When I put my computer to sleep at night, then open it in the morning, I can see the print log in the browser console. The client continues to loop through the "disconnect-reconnect" sequence as expected. However, in recent days I've noticed that it seems like after entering sleep mode, all of the JavaScript is unable to execute in the background. Instead, it seems to pile up and only executes at the moment the machine is woken up. I am trying to figure out why this is happening. |
Try to see if this is a known issue with worker-timers npm module or something OS specific |
This is an automated message to let you know that this issue has If this issue is still important, you can simply comment with a Thank you for your contribution. |
This issue was automatically closed due to inactivity. |
To solve #1361 ,I've tried MQTT version 5.3.3 recently, it's able to maintain the connection automatically when client browser tab are blured or the whole browser is minimized, which works well.
However, when the computer enters sleep mode, the heartbeat stops sending immediatly.And the weirdest thing is, I purposefully added a close callback in the MQTT method to reconnect after disconnection. However, after the computer goes into sleep and then wakes up, none of the console.log in the close callback are printed. It seems like the JavaScript code in the callback hasn't been executed at all. By the way, In my tests, I tried to manually disconnect the client from the server while in the awake state. This does trigger the code in the close callback, and it can reconnect normally.
I'm not sure if this is a problem with this MQTT.js library, the browser, or the Windows operating system.
System Info
The text was updated successfully, but these errors were encountered: