Commit 660dade5 authored by Ian Craggs's avatar Ian Craggs

fix for bug report #405992

parent 7c7dc6aa
...@@ -502,15 +502,24 @@ void MQTTProtocol_keepalive(time_t now) ...@@ -502,15 +502,24 @@ void MQTTProtocol_keepalive(time_t now)
{ {
Clients* client = (Clients*)(current->content); Clients* client = (Clients*)(current->content);
ListNextElement(bstate->clients, &current); ListNextElement(bstate->clients, &current);
if (client->connected && client->keepAliveInterval > 0 && client->ping_outstanding == 0 && if (client->connected && client->keepAliveInterval > 0 && (difftime(now, client->net.lastContact) >= client->keepAliveInterval))
Socket_noPendingWrites(client->net.socket) && {
(difftime(now, client->net.lastContact) >= client->keepAliveInterval)) if (client->ping_outstanding == 0)
{
if (Socket_noPendingWrites(client->net.socket))
{ {
MQTTPacket_send_pingreq(&client->net, client->clientID); MQTTPacket_send_pingreq(&client->net, client->clientID);
client->net.lastContact = now; client->net.lastContact = now;
client->ping_outstanding = 1; client->ping_outstanding = 1;
} }
} }
else
{
Log(TRACE_MIN, -1, "PINGRESP not received in keepalive interval for client %s on socket %d, disconnecting", client->clientID, client->net.socket);
MQTTProtocol_closeSession(client, 1);
}
}
}
FUNC_EXIT; FUNC_EXIT;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment