如何更改蚊子中自动生成的ID?

问题描述 投票:0回答:1

我已经在Raspberry Pi 2上成功安装了MOSQUITTO Broker,并且我在nord red和mosquitto之间发送消息,我想要的是在客户端连接到此处后更改由代理生成的客户端ID,这是我的配置文件:

pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
password_file /etc/mosquitto/pwfile
allow_anonymous false
#clientid_prefixes target-
max_keepalive 60
allow_zero_length_clientid true
auto_id_prefix  auto- target-

阅读Documentation之后,他们说您只需要添加到conf文件中clientid_prefixes prefix,但这没有任何帮助吗?

这里是经纪人的日志:

Sending CONNACK to mqtt_f58c6e8c.3778b (0, 0)
1587044259: Received SUBSCRIBE from mqtt_f58c6e8c.3778b
1587044259: xxxxx/# (QoS 2)
1587044259:mqtt_f58c6e8c.3778b  // this need to be changed // 
1587044259: Sending SUBACK to mqtt_f58c6e8c.3778b
node-red mosquitto
1个回答
1
投票

该clientID不是由代理生成的,它是由Node-RED用于其MQTT节点的MQTTjs库生成的。

_之后的部分将成为代理配置节点的Node-RED内部节点ID。

您可以在设置代理IP地址的代理配置下设置clientID。

auto_id_prefix仅在代理为尚未通过连接数据包发送的客户端生成客户端ID时使用(当allow_zero_length_clientid也为true时)。在这种情况下,这不会发生,因为Node-RED总是要发送一个clientID。

clientid_prefixes设置将仅限制具有匹配前缀的客户端的访问。因此,如果将其设置为clientid_prefixes target-,则必须在Node-RED中手动设置一个具有target-前缀的客户端ID,才能进行连接。

© www.soinside.com 2019 - 2024. All rights reserved.