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
After the device system sleeps and wakes up again, the PING request is not sent #2760
Comments
Interesting edge-case... While i think using There are other layers of timeout implementations that also needs to be considered (like TCP and TLS for example). If this is a system where you are using sleep periodically to preserve battery or something similar, The only thing this change would do is maybe let the client use the same connection after a sleep, provided that the server hasn't already cut the connection while the client were sleeping.
Just to clarify, I'm not arguing against such change and it certainly isn't a big one, maybe just curious where exactly the problem came from or "what prompted testing". |
Thank you for your answer First, we have this application scenario:
In addition, in the sleep state, the client and server maintain the link connection, mainly to improve the timeliness of message processing, so that it does not take too much time to connect to the server when mosquitto_connect (), We set the keepalive time. Even if there is no control message to communicate with the server, the server will send a PING packet to maintain the link connection when the keepalive time is up. If the server does not receive the keepalive packet or other control messages within 1.5 times of the keepalive time, the server will disconnect; If the PING packet is sent within 1.5 times of the keepalive time, the link connection will always be maintained; And when the device is not in sleep state, we have no problem testing the activation function. Please help me to have a look again, thank you! |
hi:
I have a problem here, please help me guide, thank you!
I am using libmosquito to develop mqtt client applications;using mosquitto_connecte () to connect the mqtt broker, and set keepalive time is 3 minutes. When a PINGREQ request is sent and the PINGRESP response message is received, I trigger to let my device system sleep for 2 minutes, and then wakes up the device system. After waiting for 1 minute, the PINGREQ request is not sent;
I found mosquito_ loop_ misc()--> mosquitto__ check_ keepalive() --> mosquitto_ time() --> clock_ gettime(CLOCK_MONOTONIC, &tp); The current time obtained is the system running time. When the system sleeps, it will not be counted. So when the system wakes up, the two minutes of the system sleep will not be counted, so waiting for one minute will not send a PINGREQ request;
Excuse me: 1) Does mosquito not support the keepalive function of the system sleep scenario? 2) Is there any good solution to this problem?
(Can we use clock_gettime (CLOCK_BOOTTIME,&tp) to solve the above problem?)
Please help to answer it, thank you!
The text was updated successfully, but these errors were encountered: