two mqtt clients

duffo64 shared this question 2 years ago
Answered

Hello,

Since I see that pybytes mechanism uses MQTT, and my client code will use MQTT as well to send messages to our internal broker, is possible to have two instances of MQTT client working together ? Hope yes...

/Claudio

Best Answer
photo

Hi Claudio,

thank you for more details.

it should be possible. You would probably just need to create another instance of mqtt client running on different port. So then you can use it with your mqtt broker. You can look at pybytes library how how mqtt client is implemented there.

Comments (3)

photo
1

Hi Claudio,

it should be possible. But currently Pybytes library connect only to one MQTT server. If we don't do it at Pycom. You will need to alter pybytes library yourself.

photo
1

Thanks Jirka, however, let me explain better what I have in mind:

I would use pybytes only for wipy fleet management (mainly firmware upgrades), and my messages would travel only between wipy's mqtt client and our internal broker. So I really hope that two mqtt client instances talking to different brokers are doable. I must work with sensible data that simply cannot be sent on the Internet in 'some' cloud.


Claudio

photo
1

Hi Claudio,

thank you for more details.

it should be possible. You would probably just need to create another instance of mqtt client running on different port. So then you can use it with your mqtt broker. You can look at pybytes library how how mqtt client is implemented there.

photo
1

Well, seems that I cannot declare another instance of the same mqtt client. I got the simple.py client instead, and it works great. Same port, different IP.

photo
1

OK nice, that's also good;)

photo
1

Please, could you mark this as solved ?

photo