eclipse / paho.mqtt.java

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

items in messageQueue in CommsCallback class cannot be consumed correctly #964

Open Gujiawei-Edinburgh opened 1 year ago

Gujiawei-Edinburgh commented 1 year ago

Please fill out the form below before submitting, thank you!

Hello,

I am trying to develop my own SDK doing something customized by using paho sdk. My receiver client interaction with MQTT broker goes :

However, in concurrent scenario, i.e. multiple requests and replies, the receiver client may fail to reply by calling MqttAsyncClient.publish(String topic, MqttMessage message).waitForCompletion(timeout) , even though the timeout value here is large.

I captured the packets by using Wireshark and found that there is a piece of information of TCP zero window when the above invocation was failed.

I dump the threads when the case occurred:

`"MQTT Rec: responder" #21 prio=5 os_prio=31 cpu=61.34ms elapsed=59.63s tid=0x00007fabf60ca000 nid=0x7903 in Object.wait() [0x000070000db2b000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(java.base@11.0.11/Native Method)

`"MQTT Call: responder" #23 prio=5 os_prio=31 cpu=78.47ms elapsed=59.42s tid=0x00007fabf68b4000 nid=0x7e03 in Object.wait() [0x000070000dd30000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(java.base@11.0.11/Native Method)

I think the receding thread was in the loop infinitely and cannot not exit, thus causes the TCP window never increases and the receiver client cannot receive any data after data.

Thanks for your work and for your consideration.