stevenlovegrove / MqttDotNet

.net Implementation of the client half of the MQTT messaging protocol. MQTT is a lightweight, open specification publish and subscribe protocol cheifly developed by IBM. Details of MQTT can be found at http://mqtt.org.
MIT License
153 stars 91 forks source link

Reduce PINGREQ frequency to KeepAliveInterval at a maximum #8

Closed CapnBry closed 11 years ago

CapnBry commented 11 years ago

The Mqtt client was sending PINGREQ messages every KeepAliveInterval / 3 seconds, regardless of any client publish activity. The v3.1 spec states that the server expects at least one message per KeepAlive interval and allows a 50% grace period after that before the client is disconnected.

This patch reduces write actitivy so that a PINGREQ timer is reset on PUBLISH, meaning a ping is only sent if a publish hasn't been sent in the past KeepAliveInterval seconds.

stevenlovegrove commented 11 years ago

That looks great. Thanks for your patch.