Commit cb6e91277f8dad93a2f09d2f1d3efce35e9cd9e0

Authored by bdrlamb
Committed by Andrew Shvayka
1 parent 6e82f4c8

Fix MQTT inactivity disconnects

MQTT clients don't send PINGREQ messages if they've recently sent [UN]SUBSCRIBE/PUBLISH messages.  The MQTT server last activity timestamp is currently only updated in response to PINGREQ messages.  This causes the server to disconnect any clients that regularly send PUBLISH messages since they don't send PINGREQ. 

This change adds reportActivity calls in response to PUBLISH, SUBSCRIBE and UNSUBSCRIBE in addition to PINGREQ.
... ... @@ -138,12 +138,24 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
138 138 break;
139 139 case PUBLISH:
140 140 processPublish(ctx, (MqttPublishMessage) msg);
  141 + transportService.reportActivity(sessionInfo);
  142 + if (gatewaySessionHandler != null) {
  143 + gatewaySessionHandler.reportActivity();
  144 + }
141 145 break;
142 146 case SUBSCRIBE:
143 147 processSubscribe(ctx, (MqttSubscribeMessage) msg);
  148 + transportService.reportActivity(sessionInfo);
  149 + if (gatewaySessionHandler != null) {
  150 + gatewaySessionHandler.reportActivity();
  151 + }
144 152 break;
145 153 case UNSUBSCRIBE:
146 154 processUnsubscribe(ctx, (MqttUnsubscribeMessage) msg);
  155 + transportService.reportActivity(sessionInfo);
  156 + if (gatewaySessionHandler != null) {
  157 + gatewaySessionHandler.reportActivity();
  158 + }
147 159 break;
148 160 case PINGREQ:
149 161 if (checkConnected(ctx, msg)) {
... ...