Skip to content

Commit

Permalink
Put keepAliveTick in more sensible location (#140)
Browse files Browse the repository at this point in the history
* Put keepAliveTick in more sensible location

In short, keepAliveTick should not be reset every time a packet is received, since, for ex, a QoS 0 packet does not require an Ack. Likely related to #128.

Steps to recreate issue:
 - Set client keepalive to 20 seconds
 - dont publish anything for > 30 seconds
 - spam the device with something like snippit below:

```
#!/bin/bash
SPAM_DELAY=1;
while :
do
   mosquitto_pub -h hostname -t /test/topic -m 'test playload'
   sleep $SPAM_DELAY;
done
```

* reset keepalive tick when send msg
  • Loading branch information
someburner authored and tuanpmt committed Jul 24, 2017
1 parent 23586bd commit c7eda33
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mqtt/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ mqtt_tcpclient_recv(void *arg, char *pdata, unsigned short len)
struct espconn *pCon = (struct espconn*)arg;
MQTT_Client *client = (MQTT_Client *)pCon->reverse;

client->keepAliveTick = 0;
READPACKET:
MQTT_INFO("TCP: data received %d bytes\r\n", len);
// MQTT_INFO("STATE: %d\r\n", client->connState);
Expand Down Expand Up @@ -746,6 +745,7 @@ MQTT_Task(os_event_t *e)

client->sendTimeout = MQTT_SEND_TIMOUT;
MQTT_INFO("MQTT: Sending, type: %d, id: %04X\r\n", client->mqtt_state.pending_msg_type, client->mqtt_state.pending_msg_id);
client->keepAliveTick = 0;
if (client->security) {
#ifdef MQTT_SSL_ENABLE
espconn_secure_send(client->pCon, dataBuffer, dataLen);
Expand Down

0 comments on commit c7eda33

Please sign in to comment.