Problem of message no send to consumer in an application where it use an unique ClientId to publish and subscribe

Hi All

I having a problem in my Java eclipse paho Application where it uses an unique ClientId (i.e pubsub219517053241931) to publish (ie, topic = sp/moc/sdd/rt-veh/) and subscribe (topic = sp/moc/req/cfg/#). There is no message send for topic sp/moc/req/cfg/# to ClientId of pubsub219517053241931.
The workaround, I did is to create unique ClientId (i.e pub219517053241931) to publish and unique ClientId (i.e sub219517053241932) to subscribe to sp/moc/req/cfg/# then it work.

Can you please let me know if this is correct behaviour?

Thank you for your help and support

Regards, Bao

1 Like

Hi,

Your Java app probably opens 2 MQTT connections using the same ClientID. This will race and the 2 connections will kick off each other from the broker constantly.

If you want the same Client to publish and subscribe (which is totally normal to do), you need to ensure they do that in the same session (= same MQTT connection).

1 Like

Thank you for answers @afa

1 Like