How to resolve org.eclipse.paho.client.mqttv3.internal.ClientState.checkForActivity issue of client?

187 views
Skip to first unread message

tushar patil

unread,
Apr 26, 2017, 10:17:58 AM4/26/17
to MQTT

I have written mqtt client in java for mosquitto broker . it works for while but after sometime if there is no traffic between my client and mqtt broker it gets disconnected with following error:


org.eclipse.paho.client.mqttv3.internal.ClientState.checkForActivity : Timed out as no activity, keepAlive=30,000 lastOutboundActivity=1,493,194,287,903 lastInboundActivity=1,493,194,270,964 time=1,493,194,317,903 lastPing=1,493,194,287,903



How do i stay connected to mqtt broker continuously? what configuration settings do i need to make ?


My current configuration of mqtt client are (following is just a snippet):     and mosquitto broker version(1.4.11) mqtt version (3.1.1)


final String brokerUrl = AppProperties.getProperty(AppConstants.MQTT_BROKER);
final String clientId = "";
final String topic = AppProperties.getProperty(AppConstants.MQTT_TOPIC);
          MemoryPersistence persistence = new MemoryPersistence();

try {

      MqttClient sampleClient = new MqttClient(brokerUrl, clientId, persistence);
            MqttConnectOptions connOpts = new MqttConnectOptions();
            connOpts.setCleanSession(true);
            if(!sampleClient.isConnected()){
                sampleClient.connect(connOpts);
            }
            LOGGER.info("Mqtt Connected to broker: "+ brokerUrl);

            sampleClient.setCallback(this);
            sampleClient.subscribe(topic);

            LOGGER.info("Subscribed");
            LOGGER.info("Listening");

        } 

On Broker in the logs i am getting following error :


1493181236: Socket error on client , disconnecting.


Any help is appreciated. Thank you.

Thomas

unread,
May 1, 2017, 11:17:25 AM5/1/17
to MQTT
Hi,

Have a look at the 

setKeepAliveInterval 

option in the docs. that might help here.

Thomas
Reply all
Reply to author
Forward
0 new messages