eclipse-paho / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.15k stars 892 forks source link

Connection to MQTT broker lost! #431

Closed bosen365 closed 5 years ago

bosen365 commented 7 years ago

I use MqttClient to subscribe to themes. When one or two items are consumed, the connectionLost method will be invoked.

My mqttclient pom.xml `

org.eclipse.paho
    <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.1.0</version>

`

jpwsutton commented 7 years ago

What is the error provided to connectionLost?

bosen365 commented 7 years ago

MemoryPersistence persistence = new MemoryPersistence(); MqttClient client = new MqttClient(bro, cid, persistence); MqttConnectOptions connOpts = new MqttConnectOptions(); connOpts.setServerURIs(new String[] { bro }); connOpts.setCleanSession(true); connOpts.setKeepAliveInterval(120); // heartbeat interval 120s connOpts.setAutomaticReconnect(true); // set reconnect automatic

But the override 'connectionLost' method will still be called。。

@Override public void connectionLost(Throwable throwable) { System.out.println("Connection lost"); }

bosen365 commented 7 years ago

MqttClient client = new MqttClient(bro, cid, persistence);

the 'cid' is form MqttClient.generateClientId()

Is it because of this reason that reconnection is unsuccessful?

jpwsutton commented 6 years ago

What version of MQTT broker are you using? And do you have a copy of the connection lost error message (from the Throwable)?

icraggs commented 5 years ago

I imagine this is now out of date. Please reopen if there is more info.