'How to resolve mosquitto bridge protocol error

I have installed mosquitto on Ubuntu18.04. I am trying to connect to azure iot hub. Below is the content of mosquitto.con:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

Below is the bridge.conf file

connection iothub-bridge
log_type all
address ripe.azure-devices.net:8883
remote_username ripe.azure-devices.net/ripe001
remote_password SharedAccessSignature sr=ripe.azure-devices.net&sig=C5t0H%2F3eCS47Xnf38s%3D&se=253402297199.516&skn=iothubowner
remote_clientid ripe001
bridge_cafile /etc/ssl/certs/ca-certificates.crt
try_private false
cleansession false
start_type automatic
bridge_insecure false
bridge_protocol_version mqttv311
bridge_tls_version tlsv1.2
notifications false
#notification_topic events/

#cleansession false
#persistence true
#max_queued_messages 0
keepalive_interval 36000
autosave_interval 30

topic # out 2 devices/ripe001/messages/events/ devices/ripe001/messages/events/
topic # in 2 devices/ripe001/messages/devicebound/ devices/ripe001/messages/devicebound/

Mosquitto service is running fine but in logs I can see protocol error.

1650357942: mosquitto version 2.0.14 starting
1650357942: Config loaded from /etc/mosquitto/mosquitto.conf.
1650357942: Starting in local only mode. Connections will only be possible from clients running on this machine.
1650357942: Create a configuration file which defines a listener to allow remote access.
1650357942: For more details see https://mosquitto.org/documentation/authentication-methods/
1650357942: Opening ipv4 listen socket on port 1883.
1650357942: Opening ipv6 listen socket on port 1883.
1650357942: Bridge local.ripe001 doing local SUBSCRIBE on topic devices/ripe001/messages/events/#
1650357942: Connecting bridge (step 1) iothub-bridge (ripe.azure-devices.net:8883)
1650357942: mosquitto version 2.0.14 running
1650357942: Connecting bridge (step 2) iothub-bridge (ripe.azure-devices.net:8883)
1650357942: Bridge ripe001 sending CONNECT
1650357942: Client local.ripe001 disconnected: Protocol error.

Mosquitto version:

mosquitto version 2.0.14

mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker.

Usage: mosquitto [-c config_file] [-d] [-h] [-p port]

 -c : specify the broker config file.
 -d : put the broker into the background after starting.
 -h : display this help.
 -p : start the broker listening on the specified port.
      Not recommended in conjunction with the -c option.
 -v : verbose mode - enable all logging types. This overrides
      any logging options given in the config file.

See https://mosquitto.org/ for more information.

I have even tried changing the tls_version from 1.2 to 1.3 but it didn't help. Any suggestions on why I am getting protocol error. Thanks



Solution 1:[1]

The default version of MQTT will be 3.1

Add the bridge_protocolo_version option to the config and it accepts mqttv31 and mqttv311

bridge_protocol_version mqttv311

Note:

Disable privilege bridge extension.

try_private false

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SairamTadepalli-MT