首页 > 解决方案 > Mosquitto bridge broker, connection refused after connecting

问题描述

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

标签: mqttmosquittobroker

解决方案


好的,所以基本上这是最终的 mosquitto 配置:

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

出于某种原因,通知默认为 true,这导致 Dyson 代理不可用。


推荐阅读