I had been successfully install MOSQUITTO Broker on my Raspberry Pi 2 and I send messages between nord red and mosquitto what I want is to change the client id generated by the broker after a client connect here is my conf file:
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-
After Reading the Documentation They Said that you only need to just add to conf file clientid_prefixes prefix but that did not work any help?
here is the logs of broker:
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
That clientID is not being generated by the broker, it is being generated by the MQTTjs library used by Node-RED for it's MQTT nodes.
The part after the _
is going to be the Node-RED internal node id for the broker config node.
You can set the clientID under the broker config where you set the broker's IP address.
auto_id_prefix
is only used when the broker is generating a clientID for clients that have not sent one with the connect packet (this is when allow_zero_length_clientid
is also true). In this case it is not happening because Node-RED is always going to sent a clientID.
The clientid_prefixes
setting will restrict access to only clients that have the matching prefix. So if you set this to clientid_prefixes target-
you will have to manually set a clientID in Node-RED that has the target-
prefix for it to be able to connect.