Bug 407627 - Client disconnecting due to timeout (no pingreq being sent)
Summary: Client disconnecting due to timeout (no pingreq being sent)
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Paho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Andrew Banks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-09 03:33 EDT by Simon Racliffe CLA
Modified: 2016-02-05 11:15 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Racliffe CLA 2013-05-09 03:33:42 EDT
When the Paho MQTT JS cleint is connected to a server and only subscribes to topics at qos 0 it gets disconnected after the timeout period if it is receiving PUBLISH messages.

In this situation the server sends PUBLISH messages to the client, but with qos 0 the client does not respond with a PUBACK meaning the server does not reset its timeout period.

I think the client is incorrectly resetting its timeout counter when it receives the PUBLISH message, and therefore doesn't send a PINGREQ and hence gets disconnected.

I am using Mosquitto as the server if that is of any relevance (I bleieve not).
Comment 1 Nick O'Leary CLA 2013-05-14 09:42:09 EDT
Confirmed - the client incorrectly resets the time-out whenever it sends or receives anything and doesn't distinguish between the two.


This causes two faults with the client:

1. as reported, if the only messages flowing are qos 0 from the server, the client never sends a PINGREQ so will be disconnected by the server.

2. if the only messages flowing are qos 0 from the client, the client never sends a PINGREQ so will never detect if the server/network hangs until the TCP connection times out which could be a long time.

Of these two scenarios, #1 is the more likely and severe. #2 is an edge case that, whilst not ideal, will at least resolve itself if the TCP connection eventually times out.

A quick fix that addresses #1, but not #2, is:

In ClientImpl.prototype._on_socket_message, move the call to reset the pinger from the start of the function to within the case block for MESSAGE_TYPE.PINGRESP. In other words, only reset the ping handling when we receive a pingrep from the broker.



The proper way to handle keepalive logic is to track last-sent and last-received times separately and send a ping when either one exceeds the keepalive time.
Comment 2 Andrew Banks CLA 2013-06-25 04:59:49 EDT
AQdded extra timer.