Skip to main content
Version: Next

Mosquitto Configuration

Configuring mosquitto bind address and port​

Configuring a mosquitto port and bind address in thin-edge.io is a three-step process.

note

The mqtt.bind.port and the mqtt.bind.address can be set/unset independently.

Step 1: Disconnect thin-edge.io edge device​

The thin-edge.io device has to be disconnected from the cloud using the tedge command

tedge disconnect c8y

#or
tedge disconnect az

#or
tedge disconnect aws

Step 2: Set the new mqtt port and bind address​

Use the tedge command to set the mqtt.bind.port and mqtt.bind.address with a desired port and bind address as below.

sudo tedge config set mqtt.bind.port 1024
sudo tedge config set mqtt.bind.address 127.0.0.1
note

The bind_address is the address of one of the device network interface. For example, this can be get as ifconfig | grep inet or set it to 0.0.0.0

This will make sure that all the mqtt clients use the newer port and the bind address that has been set once the device is connected to the cloud as in step 3.

Step 3: Connect the device to cloud​

Use the tedge command to connect to the desired cloud as below.

tedge connect c8y

#or
tedge connect az

#or
tedge connect aws

This will configure all the services (mosquitto, tedge-mapper-c8y.service, tedge-mapper-az.service, tedge-mapper-aws.service, tedge-agent.service) to use the newly set port and the bind address.

Common Errors​

The below example shows that we cannot set a string value for the port number.

tedge config set mqtt.bind.port '"1234"'
Output
Error: failed to set the configuration key: mqtt.bind.port with value: "1234".

Caused by:
Conversion from String failed

Updating the mqtt port and bind address (host) in collectd and for collectd-mapper​

Update the collectd.conf with the new port and host in <Plugin mqtt>.

Then, restart the collectd service.

sudo systemctl restart collectd

After changing the mqtt port and host, then connect to the cloud using tedge connect c8y/az. Then (Steps 1-3) the collectd-mapper has to be restarted to use the newly set port and bind address (host).

Restart the tedge-mapper-collectd service.

sudo systemctl restart tedge-mapper-collectd