Closed bosen365 closed 5 years ago
What is the error provided to connectionLost?
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"); }
MqttClient client = new MqttClient(bro, cid, persistence);
the 'cid' is form MqttClient.generateClientId()
。
Is it because of this reason that reconnection is unsuccessful?
What version of MQTT broker are you using? And do you have a copy of the connection lost error message (from the Throwable)?
I imagine this is now out of date. Please reopen if there is more info.
I use MqttClient to subscribe to themes. When one or two items are consumed, the connectionLost method will be invoked.
My mqttclient pom.xml `
`