0

Protocol: mqtt
Version: 3.1.1
Gateway model: CloudGate Ethernet CG0102

I'm publishing json message from my gateway which is connected to an open source Emqx broker (broker.emqx.io) port 1883 for a test. I tried to consume the messages by connecting to it with MQTTX by giving the following informations: Name, Client_ID, Host, Port, Username and Password, and then giving my topic which is my_topic.

The problem is nothing appear in my MQTTX while the given broker informations are good and similar to those in my gateway. Why ?

Also I would like in the future to use my own mqtt broker mounted on my laptop ? Any simple references where I could start to make such thing ? I already use mqtt to consume messages with python from remote broker but never try to build one to receive messages from my remote gateway.

I'm working on a ubuntu bionic VM

Thib
  • 11
  • 1
  • 4
  • Just to be clear are you using the same `Client_ID` for both? – hardillb Mar 30 '22 at 13:54
  • @hardillb yes and my connection stops after few seconds. I don't know what happens – Thib Mar 30 '22 at 14:45
  • Also there should only be one question at a time, but to answer the second part, you just pick one of the many OpenSource brokers and install them on your laptop. But recommending software is off topic for Stack Overflow. – hardillb Mar 30 '22 at 15:39

1 Answers1

0

Client_ID needs to be unique for every client, so you can not reuse Client_ID between clients.

The MQTT spec says that the broker should kick the oldest client off when a new client connects with the same Client_ID. This normally leads to a fight between the 2 clients as they both try and reconnect kicking each other off.

hardillb
  • 54,545
  • 11
  • 67
  • 105
  • But when I update broker settings in my gateway by using new client_id and put it in my new MQTTX connection settings. Then connect for the fisrt time, it stops after few seconds – Thib Mar 30 '22 at 15:03
  • You CAN NOT use the same client_id in MQTTX and the gateway. They MUST be different. Also as you are using a public broker, the values should probably be random to prevent any other users picking the same – hardillb Mar 30 '22 at 15:10
  • Ok I use two differents client_id but still not understanding how to receive my messages since nothing happens – Thib Mar 30 '22 at 15:28
  • OK, then you need to add more information to your question, What is the gateway? Have you looked at it's logs to see first that it is actually connected and that it is publishing data? Have you tried using something like Wireshark to see the actual messages the gateway is sending? – hardillb Mar 30 '22 at 15:35
  • Basic testing shows messages are working as expected with `my_topic` on the broker mentioned. – hardillb Mar 30 '22 at 15:36
  • Yes the gateway is well connected to the broker and show me how many json messages has been published since last connection. I never use Wireshark but I could try. Could you share with me what kind of messages you receive to check if it matches with publish messages ? Thank you for your help – Thib Mar 30 '22 at 19:25
  • [Edit](https://stackoverflow.com/posts/71678292/edit) the original question to add all the details I asked for. – hardillb Mar 30 '22 at 22:15
  • I edited my question with the gateway model for now. I just need to make sure the publish in mqtt is correct – Thib Mar 31 '22 at 08:00