Mosquitto bridge broker, connection refused after connecting - mqtt

I'm developing a webapp that connects to a local broker (dyson), the problem is that I can't directly connect to MQTT protocol directly from browser, and I cant edit the dyson broker config to open websockets ports. So Im creating a new broker with open websockets bridged to the dyson broker. I've tested direct access via server MQTT to dyson and works well, I can retrieve data from it. But when I try to connect from my broker it connects and then throws connection refused.
This is my broker config:
listener 9001
protocol websockets
allow_anonymous true
listener 1883
protocol mqtt
allow_anonymous true
connection paho33095379815290
address 10.0.0.248:1883
remote_clientid paho33095379815290
remote_username VS9-EU-233232A
remote_password ******
bridge_protocol_version mqttv311
cleansession true
try_private false
topic # both 0
log_type all
this are the logs i get:
135848336: Bridge local.paho33095379815290 doing local SUBSCRIBE on topic #
135848336: Connecting bridge (step 1) paho33095379815290 (10.0.0.248:1883)
135848336: Connecting bridge (step 2) paho33095379815290 (10.0.0.248:1883)
135848336: Bridge paho33095379815290 sending CONNECT
135848336: Received CONNACK on connection local.paho33095379815290.
135848336: Connection Refused: broker unavailable

Ok, so basically this is the final mosquitto config:
log_type all
listener 9001
protocol websockets
allow_anonymous true
listener 1883
protocol mqtt
allow_anonymous true
#bridge
connection dyson-fan
address 10.0.0.248:1883
remote_clientid paho33135379815290
remote_username VS9-EU-KFA2511A
remote_password *****
bridge_protocol_version mqttv311
try_private false
notifications false
cleansession true
topic # both 0
For some reason, notifications to default true, which was making the Dyson broker unavailable.

Related

I can't get any data from my broker with mosquitto_sub over the internet

in localhost, my broker works great, but when I use broker IP on another device to connect over the internet that's not work,
Websocket is fine
I use this command to subscribe on topic and get the retained messages
mosquitto_sub -h *.*.*.* -p 1883 -t mrt_connections/#
in localhost and when I used VPN I get current information, but when I use broker IP to use with another device over the internet I can't get any data
this log when I used Ip over the internet
1673794013: New connection from ****.****.***.**** on port 1883.
1673794013: New client connected from ****.****.***.**** as auto-48259EF8-9CF7-9CF5-3C2C-20FA8265C33A (p2, c1, k60).
1673794013: No will message specified.
1673794013: Sending CONNACK to auto-48259EF8-9CF7-9CF5-3C2C-20FA8265C33A (0, 0)
1673794017: New connection from *.*.*.* on port 1883.
I guessed that maybe port 1883 is blocked by ISP but another broker with the same port working, I test many IP but the problem is still alive,
can anybody explain to me what is a problem
thanks
I used version 2.0.15
config file
allow_anonymous true
listener 1883 *.*.*.*
log_type all
log_dest topic
log_dest stdout
Finally, I found the problem, the port was blocked by ISP and now MQTT works fine on port 443

Mosquitto bridge mode error "Client local.XXXXXX.awsiot disconnected: protocol error."

I'm trying to create a bridge between my local mosquitto broker and AWS IOT. Unfortunatelly i cannot succesfully make it work :(((
I setup the mosquitto.config file like that:
port 1883
allow_anonymous true
log_type all
tls_version tlsv1.2
bind_address 0.0.0.0
listener 8883
protocol mqtt
connection awsiot
address al3qi2b1mxp67-ats.iot.us-east-2.amazonaws.com:8883
topic # both 0
try_private false
bridge_protocol_version mqttv311
bridge_keyfile C:\Program Files\mosquitto\certs\private.key
bridge_certfile C:\Program Files\mosquitto\certs\certificate.pem
bridge_cafile C:\Program Files\mosquitto\certs\AmazonRootCA1.pem
I'm getting this result in cmd running command mosquitto.exe -c mosquitto.conf
1642763152: The 'port' option is now deprecated and will be removed in a future version. Please use 'listener' instead.
1642763152: The 'bind_address' option is now deprecated and will be removed in a future version. The behaviour will default to true.
1642763152: mosquitto version 2.0.14 starting
1642763152: Config loaded from mosquitto.conf.
1642763152: Opening ipv6 listen socket on port 8883.
1642763152: Opening ipv4 listen socket on port 8883.
1642763152: Opening ipv4 listen socket on port 1883.
1642763152: Bridge local.DESKTOP-DC703HB.awsiot doing local SUBSCRIBE on topic #
1642763152: Connecting bridge awsiot (al3qi2b1mxp67-ats.iot.us-east-2.amazonaws.com:8883)
1642763152: Bridge DESKTOP-DC703HB.awsiot sending CONNECT
1642763152: mosquitto version 2.0.14 running
1642763153: Client local.DESKTOP-DC703HB.awsiot disconnected: protocol error.

mqtt broker bridge (in windows machine)

I'm working in mqtt broker bridge, I have to connect local mosquitto to remote mosquitto.
connection remote-mosquitto-bridge
address 10.1.0.9:1883
topic test both 1
Above code is added in mosquitto.conf file for connect remote machine(10.1.0.9 is my remote)
its enough for message sharing to local to remote
You need config the listener port
ex:
if your diagram is like that
broker 1 => broker 2
Broker 1 mosquitto.config:
connection remote-mosquitto-bridge
address 10.1.0.9:1883
topic # both 0
Broker 2 mosquitto.config:
port 1883
listener 8883
This work for me.
source:
https://medium.com/jungletronics/mosquitto-bridge-5b44e9687fb3

Secure bridge between a local mosquito and Watson-iot

I need your help on the MQTT bridging. Currently I can successfully bridge the local MQTT to the Watson IOT messaging, but only in inscure mode, ie. 1883 port. So I got the server certificate by this command
openssl s_client -connect myorg.messaging.internetofthings.ibmcloud.com:8883 -showcerts > server.crt
and removed two lines from the top and two lines from the bottom. When I try to connect this in a secure mode, I get the socket error as below. Could anyone help me on this?
mosquitto.conf
connection bridge-to-watsoniot
bridge_insecure false
bridge_certfile /home/pi/server.crt
address myorg.messaging.internetofthings.ibmcloud.com:8883
cleansession false
try_private false
bridge_attempt_unsubscribe false
notifications true
notification_topic iot-2/type/Raspberry/id/my_mqtt_gateway/evt/status/fmt/raw
remote_username use-token-auth
remote_password ***************
remote_clientid g:myorg:Raspberry:my_mqtt_gateway
topic iot-2/type/+/id/+/cmd/+/fmt/+ in iot-2/type/+/id/+/cmd/+/fmt/+
topic iot-2/type/+/id/+/evt/+/fmt/+ out iot-2/type/+/id/+/evt/+/fmt/+
connection_messages true
mosqutto.log
1487240737: mosquitto version 1.4.10 (build date Thu, 25 Aug 2016 10:12:09 +0100) starting
1487240737: Config loaded from mosquitto.conf.
1487240737: Opening ipv4 listen socket on port 1883.
1487240737: Opening ipv6 listen socket on port 1883.
1487240737: Connecting bridge bridge-to-watsoniot (myorg.messaging.internetofthings.ibmcloud.com:8883)
1487240738: New connection from 127.0.0.1 on port 1883.
1487240738: New client connected from 127.0.0.1 as mqttjs_93a3961c (c1, k10, u'foo').
1487240738: New connection from 127.0.0.1 on port 1883.
1487240738: New client connected from 127.0.0.1 as mqttjs_618c88ab (c1, k10).
1487240739: Socket error on client local.g:myorg:Raspberry:my_mqtt_gateway, disconnecting.
1487240747: New connection from 192.168.82.130 on port 1883.
The bridge_certfile directive is for a client side certificate for the local broker to use to authenticate it's self with the remote broker. You should not need to this to connect to Watson IoT.
You should be using the bridge_cafile or bridge_capath to point to a the CA certificate that signed the Watson IoT certificate so the local broker can verify that the remote end is who they say they are.

Disconnects all my clients suddenly -> Warning: Received PUBREL from <client-id> for an unknown packet identifier 247

Warning: Received PUBREL from 14444141 for an unknown packet identifier 247.
Socket error on client <unknown>, disconnecting.
Setup
A-Broker
max_inflight_messages 50000
max_queued_messages 10000
port 1883
persistence true
persistence_file mosquitto.db
persistence_location /var/lib/mosquitto/
log_dest syslog
log_dest stdout
log_dest topic
log_dest stderr
connection_messages true
log_timestamp true
allow_anonymous true
log_timestamp true
# bridge
connection ToMQTTClassic123
address <ip>:1883
start_type automatic
topic # both 2 SAMPLE/ SAMPLE/
How do mitigate this issue, my broker seems to disconnects its clients suddenly I dont know why?
Im currently using mqtt v 1.4.10 for the broker
And currently using mqtt v1.1.0 for the client paho
PS: All our clients used QOS2 with fixed client id when connecting to the broker.

Resources