1) How to determine the Mosquitto bridge connection name.
The snippet written below is from the EMQx documentation (http://emqtt.io/docs/v2/bridge.html#mosquitto-conf)
connection emqttd
address 127.0.0.1:2883
topic sensor/# out 2
the connection name - emqttd is written on what basis?
2) I have a tcp connection open from EMQX on the host 172.22.25.53 and port 2883.
When i try connecting from the same system. It works absolutely fine. But from a different system, I get this error
C:\Program Files\mosquitto>mosquitto.exe -c mosquitto.conf -v
1542182003: mosquitto version 1.5.3 starting
1542182003: Config loaded from mosquitto.conf.
1542182003: Opening ipv6 listen socket on port 1883.
1542182003: Opening ipv4 listen socket on port 1883.
1542182003: Bridge local.AOI146.emq#172.22.25.53 doing local SUBSCRIBE on topic BA/#
1542182003: Connecting bridge emq#172.22.25.53 (172.22.25.53:2883)
1542182003: Bridge AOI146.emq#172.22.25.53 sending CONNECT
1542182003: Error creating bridge: Unknown error.
1542182003: Warning: Unable to connect to bridge emq#172.22.25.53.
My mosquitto.conf file is:
connection emqx
address 172.22.25.53:2883
cleansession false
topic AB/# both 2
The connection name is the value after connection in the configuration file. As described in the bridge section of the mosquitto.conf man page
e.g.
connection foo
Will result in a connection name of foo.
172.22.25.53 is in the reserved range 172.16.0.0 – 172.31.255.255, I'm going to guess you are running emq in a docker container and you are trying to access the container using it's Docker internal IP address. You will need to expose the port on your host machine to be able to access it from a remote machine.
Related
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
I am running Mosquitto MQTT broker on the localhost of my PC and I want to publish or subscribe data through MQTT with Mosquitto from a remote IP (another PC). Both the PCs are connect to the same Wifi public network. I have disable the firewall of the two PCs and I am able to ping one another on command prompt. I have look up on several websites and tried editing the config file of the Mosquitto MQTT broker by adding these two lines.
listener 1883
allow_anonymous true
I have started the Mosquitto broker by executing mosquitto -c mosquitto.conf -v
The following is the log appear the mosquitto start.
C:\Program Files\mosquitto>mosquitto -c mosquitto.conf -v
1665133477: mosquitto version 2.0.15 starting
1665133477: Config loaded from mosquitto.conf.
1665133477: Opening ipv6 listen socket on port 1883.
1665133477: Opening ipv4 listen socket on port 1883.
1665133477: mosquitto version 2.0.15 running
However, on the publishing PC, it prompts the error below.
C:\Program Files\mosquitto>mosquitto_pub -h XXX.XXX.XX.X -t Test -m "Hello World" -p 8883 -d
Error: No connection could be made because the target machine actively refused it.
The situation is same for subscribing. I am currently using the latest version of Mosquitto 2.0.15. Can anyone help me on this situation? Your help would be much appreciated. Thanks in advance!
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.
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
I am trying to bridge my local (Windows) MQTT mosquitto broker to test.mosquitto.org. Unfortunately it raises a Unknown Error.
I am using the same configuration that is used in this question
Verify that local mosquitto MQTT Broker is bridged to test.mosquitto.org
Config file:
connection test
address test.mosquitto.org
topic oust_topicst_topic out 0
try_private false
notifications false
bridge_attempt_unsubscribe true
Output:
1489747961: mosquitto version 1.4.11 (build date 20/02/2017 23:24:29.40) starting
1489747961: Config loaded from Configurations/bridge.conf.
1489747961: Opening ipv6 listen socket on port 1883.
1489747961: Opening ipv4 listen socket on port 1883.
1489747961: Bridge local.NicolasJourdan.test doing local SUBSCRIBE on topic oust_topicst_topic
1489747961: Connecting bridge test (test.mosquitto.org:1883)
1489747961: Bridge NicolasJourdan.test sending CONNECT
1489747961: Error creating bridge: Unknown error.
1489747961: Warning: Unable to connect to bridge test.
1489747969: mosquitto version 1.4.11 terminating
What could produce this error? I am not running another instance of mosquitto and test.mosquitto.org is up
First question is whether you are running a local broker or just connecting as a client.
If you are running a broker try to first run mosquitto with -c "path to config file" to see whether your config file has an error in it. Run in terminal (example on linux):
mosquitto -c /etc/mosquitto/mosquitto.conf
If there is an error the console will show it and you take it from there.
Next, try to format your topics like this (it is called topic remapping):
topic test out 0 local/ local/
Now you can publish to local/test from your code or terminal, and the message will be published to local/test on the remote broker, which will receive messages by suscribing to the same topic.
Update September 2019
The bug on Windows as described below has reportedly been fixed in version 1.6.5 of Mosquitto.
There appears to be a bug with Mosquitto running on Windows that prevents bridging from working.
On Windows the socket is not ready before Mosquitto attempts to connect.
See https://github.com/eclipse/mosquitto/issues/478 and https://github.com/eclipse/mosquitto/issues/580. This describes the underlying issue on Windows:
After checking the code I found that the statement in bridge.c .... makes a non blocking socket connect.
...
So the the next command ... sometimes fails, since the connection has not been established, as the previous connect is non-blocking.