How to resolve org.eclipse.paho.client.mqttv3.internal.ClientState.checkForActivity issue of mqtt [message #1760536] |
Fri, 28 April 2017 07:38 |
Tushar Patil Messages: 1 Registered: April 2017 |
Junior Member |
|
|
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):
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);
sampleClient.setCallback(this);
if(!sampleClient.isConnected()){
sampleClient.connect(connOpts);
}
LOGGER.info("Mqtt Connected to broker: "+ brokerUrl);
sampleClient.subscribe(topic);
LOGGER.info("Subscribed");
LOGGER.info("Listening");
}
------------------------------------------------------------------------------------------------------------
Any help is appreciated. Thank you.
|
|
|
Powered by
FUDForum. Page generated in 0.02748 seconds