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

Process incoming packet first in loop() #15

Closed
wants to merge 1 commit into from

Conversation

arkusuma
Copy link

Hi Nick,

I'm writing a GPRSClient. I've got a case where I can only call PubSubClient::loop() after a long operation (GPRSClient::write() with timeout of 30 seconds, way beyond MQTT_KEEPALIVE). On that period a MQTT packet came (PingResp in this case). When I finally call PubSubClient::loop() it disconnect the connection because of PingOutstanding timeout, even though the packet is there in GPRSClient RX buffer. This patch fix that problem by handling incoming packet first before checking for timeout.

Regards,
Anugrah

@knolleary
Copy link
Owner

The keepalive timer works both ways. If your client is not going to respond to a ping for longer than the keepalive interval, you are at risk of the server timing you out.

For your scenario, the correct solution is to increase the value of MQTT_KEEPALIVE to be bigger than any other timeout you have that may prevent the client from responding to a ping.

@knolleary knolleary closed this Nov 25, 2012
remspoor pushed a commit to remspoor/pubsubclient that referenced this pull request May 29, 2016
The former does not yield to the built-in wifi code.
See discussion in knolleary#15
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

Successfully merging this pull request may close these issues.

2 participants