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.
This commit is contained in:
		
							parent
							
								
									6e82f4c8f0
								
							
						
					
					
						commit
						cb6e91277f
					
				@ -138,12 +138,24 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
 | 
			
		||||
                break;
 | 
			
		||||
            case PUBLISH:
 | 
			
		||||
                processPublish(ctx, (MqttPublishMessage) msg);
 | 
			
		||||
                transportService.reportActivity(sessionInfo);
 | 
			
		||||
                if (gatewaySessionHandler != null) {
 | 
			
		||||
                    gatewaySessionHandler.reportActivity();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case SUBSCRIBE:
 | 
			
		||||
                processSubscribe(ctx, (MqttSubscribeMessage) msg);
 | 
			
		||||
                transportService.reportActivity(sessionInfo);
 | 
			
		||||
                if (gatewaySessionHandler != null) {
 | 
			
		||||
                    gatewaySessionHandler.reportActivity();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case UNSUBSCRIBE:
 | 
			
		||||
                processUnsubscribe(ctx, (MqttUnsubscribeMessage) msg);
 | 
			
		||||
                transportService.reportActivity(sessionInfo);
 | 
			
		||||
                if (gatewaySessionHandler != null) {
 | 
			
		||||
                    gatewaySessionHandler.reportActivity();
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case PINGREQ:
 | 
			
		||||
                if (checkConnected(ctx, msg)) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user