2
我的服務使用paho mqtt時出現問題。它超時但沒有連接丟失的報告。有沒有人有解決這個問題的辦法?如何解決此問題mqtt Paho超時但未報告連接丟失
public void connect(String client_id) {
String tmpDir = System.getProperty("java.io.tmpdir");
MqttDefaultFilePersistence dataStore = new MqttDefaultFilePersistence(tmpDir);
MqttConnectOptions options = new MqttConnectOptions();
options.setKeepAliveInterval(120);
try {
_client = new MqttClient(_url, MqttClient.generateClientId(), dataStore);
_client.connect(options);
_client.setCallback(this);
_client.subscribe(TOPIC);
LOGGER.info("Subscribed to " + Arrays.toString(TOPIC));
LOGGER.info("MAX CORES " + MAX_CORES);
} catch (MqttException e) {
LOGGER.log(Level.INFO, "Mosquitto Error: " + e.fillInStackTrace());
connect(null);
}
}
@Override
public void messageArrived(final String topic, final MqttMessage message) throws Exception {
threadPool.execute(new Runnable(){// code});
}
使用MQTT v 1.0.0
Nov 6, 2015 2:36:52 AM org.eclipse.paho.client.mqttv3.internal.ClientState checkForActivity
SEVERE: paho-595916529752865: Timed out as no activity, keepAlive=120,000 lastOutboundActivity=1,446,777,172,455 lastInboundActivity=1,446,777,117,734 time=1,446,777,412,455 lastPing=1,446,777,172,454
你將不得不給我們一些更多的上下文給任何人來幫助。諸如此類,它是否超時作爲連接的一部分,或者經過一段時間不發送數據之後?您設置了什麼KeepAlive期限? – hardillb
原來是60秒,現在我改爲120秒 – david
在這個問題上有什麼好運? –