Open posfaig opened 7 years ago
Did the publish time out or fail immediately? Perhaps the exception was thrown from here: https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/Token.java#L112 If so, it failed immediately.
It timed out. The timeout was set to 10 seconds, and the log snippet above nicely shows that 10 seconds passed between the INFO log and the exception.
You are probably right, as it can be seen from the logs included above that the exception was thrown from Token.java:112. But I am not sure what does this mean exactly, and whether it is expected or not with Qos 0.
just found this. annoying!
We stumbled upon the same issue and solved it ourself by using the MqttAsyncClient
and simply don't call waitForCompletion
.
I think I am hitting another issue with this bug. When I publish at QOS 0, the max infight increases unless a subscriber consumers a message. This doesnt seem correct, as QOS 0 requires no acknowledgement. So why would the max inflight continue to increase w QOS 0. Whats the fix here?
MQTT client waits for ACK even when publishing a message with QoS 0, but the broker does not send any ACK (as expected), so the call of the publish() method will block until timeout.
Code: logger.info("respMessage.getQos()=" + respMessage.getQos()); getClient().publish(responseTopic, respMessage);
Log: 20:13:22,056 INFO [hu.alerant.xsenso.server.iotregapp.mqtt.sublisteners.RequestListener] (MQTT Call: regapp1) respMessage.getQos()=0 20:13:32,062 ERROR [hu.alerant.xsenso.server.iotregapp.mqtt.sublisteners.RequestListener] (MQTT Call: regapp1) Error while sending response: Timed out waiting for a response from the server (32000) 20:13:32,064 ERROR [stderr] (MQTT Call: regapp1) Timed out waiting for a response from the server (32000) 20:13:32,064 ERROR [stderr] (MQTT Call: regapp1) at org.eclipse.paho.client.mqttv3.internal.Token.waitForCompletion(Token.java:112) 20:13:32,064 ERROR [stderr] (MQTT Call: regapp1) at org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(MqttToken.java:67) 20:13:32,064 ERROR [stderr] (MQTT Call: regapp1) at org.eclipse.paho.client.mqttv3.MqttClient.publish(MqttClient.java:399) 20:13:32,064 ERROR [stderr] (MQTT Call: regapp1) at hu.alerant.xsenso.server.iotregapp.mqtt.sublisteners.RequestListener.messageArrived(RequestListener.java:125) 20:13:32,065 ERROR [stderr] (MQTT Call: regapp1) at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:467) 20:13:32,065 ERROR [stderr] (MQTT Call: regapp1) at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:379) 20:13:32,065 ERROR [stderr] (MQTT Call: regapp1) at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:183) 20:13:32,065 ERROR [stderr] (MQTT Call: regapp1) at java.lang.Thread.run(Thread.java:745)