peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
549 stars 116 forks source link

Esp32 How to use mqtt_ As to connect the brokers of two servers? #113

Open oaux opened 1 year ago

oaux commented 1 year ago

I tried to create two MQTTclients, but many wifi error prompts

peterhinch commented 1 year ago

I don't think this can work. You would have two sockets (one on each client) connected to the same port. There is no mechanism for determining the correct destination socket for an incoming packet. You might be able to do something if you could ensure that the two brokers used different ports.

oaux commented 1 year ago

If two brokers use different ports, how to handle it? I tried to hide the WiFi reconnection code, but it would cause the two links to switch repeatedly

peterhinch commented 1 year ago

Good point. I think it would involve a lot of work. The module was designed on the basis of a one-to-one correspondence between client and broker.