paho.mqtt.java icon indicating copy to clipboard operation
paho.mqtt.java copied to clipboard

Callback not invoked when using share subscription if publish and subscribe message on the same host

Open SomberOfShadow opened this issue 2 years ago • 1 comments

Hello everyone

Recently I use MQTT java paho client API, version is MQTTv5 1.2.5 on my local maven project.

I found a very strange issue:

If publish message to the topic and then subscribe this topic on the same host, it can not receive message usually, which callback is not invoked.

However, if publish messages to the topic on other host, then it will succeed to subscribe the topic and receive messages.

I don't know whether any others encounter this issue.

Looking forward to your reply.

Thanks you!

  • [ ] Bug exists Release Version 1.2.5 ( Master Branch)
  • [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)

SomberOfShadow avatar Mar 08 '22 03:03 SomberOfShadow

After trouble-shooting, I found the root cause . I use thread pool to start publish client and another thread pool to start subscribe client, and use thread name as client Id. However, I don't know why these two thread pools' thread names are the same. As a result, the publish client Id and subscribe Id have conflicts.

Finally, I use "publish" as publish client id prefix and "subscribe" as subscribe client id prefix to solve this issue.

SomberOfShadow avatar Mar 15 '22 05:03 SomberOfShadow