两个paho.mqtt客户端订阅相同的客户端区域 [英] Two paho.mqtt clients subscribing to the same client localy

查看:844
本文介绍了两个paho.mqtt客户端订阅相同的客户端区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定是否可以有两个paho.mqtt客户端( https://eclipse.org/paho/clients/python/docs/)订阅同一台服务器.客户端和服务器都在同一主机上运行.我的目的是让两个客户端使用不同的凭据订阅同一台服务器(在我的情况下是带有mqtt插件的rabbitmq),以便我可以按虚拟主机(而不是按主题对我的有效负载进行排序),因为我无法控制主题. /p>

目前,我的观察是客户端只是保持重新连接,这表明我做错了事,或者一次只能有一个客户端连接到MQTT服务器...

这是一个问题-您是否能够运行一个以上订阅同一台服务器的客户端,而所有客户端和服务器都在本地运行?


似乎带有MQTT插件的RabbitMQ允许实现此功能.一个人可以将两个用户配置为可以访问单独的虚拟主机,仅通过这样做,就可以隔离有效负载.我的方案是配置两个客户端,以便区分谁发送了哪个有效负载,并且在本地可以生成镜像客户端以消耗相关用户的有效负载.

非常感谢@hardillb帮助解决了这个问题和相关问题.

解决方案

每个客户端必须具有唯一的客户端ID,当新客户端使用相同的客户端ID连接时,代理将启动最早的客户端.除此之外,您还可以运行尽可能多的客户端,这些客户端可以从可以连接到代理的任何地方进行连接

I'm trying to find out if it is possible to have two paho.mqtt clients (https://eclipse.org/paho/clients/python/docs/) 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?


Edit:

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.

解决方案

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

这篇关于两个paho.mqtt客户端订阅相同的客户端区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆