如何更改 mosquitto 中自动生成的 ID?
how to change auto generated id in mosquitto?
我已经在我的 Raspberry Pi 2 上成功安装了 MOSQUITTO Broker,我在 nord red 和 mosquitto 之间发送消息,我想要的是更改由客户端连接后的代理是我的 conf 文件:
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
clientID 不是由代理生成的,它是由 Node-RED 用于其 MQTT 节点的 MQTTjs 库生成的。
_
之后的部分将成为代理配置节点的 Node-RED 内部节点 ID。
您可以在设置代理 IP 地址的代理配置下设置 clientID。
auto_id_prefix
仅在代理为尚未发送连接数据包的客户端生成 clientID 时使用(此时 allow_zero_length_clientid
也是如此)。在这种情况下,它不会发生,因为 Node-RED 总是会发送一个 clientID。
clientid_prefixes
设置将限制访问仅具有匹配前缀的客户端。因此,如果将其设置为 clientid_prefixes target-
,则必须在 Node-RED 中手动设置一个具有 target-
前缀的 clientID 才能连接。
我已经在我的 Raspberry Pi 2 上成功安装了 MOSQUITTO Broker,我在 nord red 和 mosquitto 之间发送消息,我想要的是更改由客户端连接后的代理是我的 conf 文件:
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
clientID 不是由代理生成的,它是由 Node-RED 用于其 MQTT 节点的 MQTTjs 库生成的。
_
之后的部分将成为代理配置节点的 Node-RED 内部节点 ID。
您可以在设置代理 IP 地址的代理配置下设置 clientID。
auto_id_prefix
仅在代理为尚未发送连接数据包的客户端生成 clientID 时使用(此时 allow_zero_length_clientid
也是如此)。在这种情况下,它不会发生,因为 Node-RED 总是会发送一个 clientID。
clientid_prefixes
设置将限制访问仅具有匹配前缀的客户端。因此,如果将其设置为 clientid_prefixes target-
,则必须在 Node-RED 中手动设置一个具有 target-
前缀的 clientID 才能连接。