简体   繁体   English

MQTT 发布者是否可以在主题上定义允许的订阅者?

[英]MQTT is it possible for publisher to define allowed subscribers on topic?

I have a basic MQTT question: If I have a broker that I can't configure myself but publish or subscribe anonymous, is it possible for the publisher to define the allowed clients on the topic?我有一个基本的 MQTT 问题:如果我有一个无法自己配置但匿名发布或订阅的代理,发布者是否可以定义该主题的允许客户端?

Eg with mosquitto I can define a ACL file but only at the broker site.例如,使用 mosquitto 我可以定义一个 ACL 文件,但只能在代理站点上定义。

If it is not possible, what would be the best way to encrypt the published data with python?如果不可能,用 python 加密已发布数据的最佳方法是什么?

No, a MQTT publisher has absolutely no knowledge or control over which clients can subscribe to the topic it publishes messages.不,MQTT 发布者完全不知道或控制哪些客户端可以订阅它发布消息的主题。

MQTT is a pub/sub protocol, one of it's key tenets is to totally decouple the publisher from the subscriber. MQTT 是一种发布/订阅协议,它的一个关键原则是将发布者与订阅者完全解耦。 The may be anything from 0 to n subscribers when a message is published.发布消息时,可能是 0 到 n 个订阅者。

The only option of control is as mentioned in the comments by @GDagger is that you could encrypt the payload so only authorised subscribers could decrypt it.正如@GDagger 在评论中提到的,唯一的控制选项是您可以加密有效负载,以便只有授权订阅者才能解密它。 Since MQTT payloads are just a collection of bytes you can send anything you want (with in the 256mb size limit)由于 MQTT 有效负载只是一组字节,您可以发送任何您想要的内容(大小限制为 256mb)

On the other hand the broker has complete control, it can use ACLs to decide which clients can publish or subscribe to which topics.另一方面,broker 拥有完全的控制权,它可以使用 ACL 来决定哪些客户端可以发布或订阅哪些主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM