Greg0ry Greg0ry - 1 year ago 62
Python Question

Two paho.mqtt clients subscribing to the same client localy

I'm trying to find out if it is possible to have two paho.mqtt clients ( subscribing to the same server. Both clients and server are running on the same host. My aim is to have two clients subscribing with different credentials to the same server (which in my case is rabbitmq with mqtt plugin) so I can sort my payloads by vhosts (not by topic since I don't have control over topics).

My observation at the moment is that the clients just keep reconnecting which would suggest I'm either doing something wrong or that there can be only one client connected to the MQTT server at a time...

So here is the question - was you able to run more than one client subscribed to the same server where all clients and server were running locally?


It seems RabbitMQ with MQTT plugin allows to achieve this functionality. The one could configure two users to have access to separate vhosts and just by doing this payloads get segregated. My scenario was to configure two clients so I could distinguish who had sent which payload, and localy I could spawn mirror clients to consume payload of related users.

Many thanks to @hardillb who helped with this question and with related question.

Answer Source

Each client must have a unique client id, the broker will kick off the oldest client when a new one connects with the same client id. Other than that you can run as many clients as you want connecting from anywhere that can reach the broker

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download