1

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

Community
  • 1
  • 1
nicoj
  • 23
  • 2
  • 4
  • What do you get if you add -v to the command line to enable verbose logging? – hardillb Mar 17 '17 at 11:30
  • This already is the output of verbose logging. If I do not add -v there is no output. Is there maybe another logfile with extended messages or something similar? – nicoj Mar 17 '17 at 11:48
  • OK, that config works fine from my Linux box. Have you tried turning off any firewall you have? Also can you ping test.mosquitto.org from the same machine? – hardillb Mar 17 '17 at 13:05
  • I have tried now and it still doesn't work :( I am able to ping the broker. Ironically it also works from a linux machine in the same network! – nicoj Mar 17 '17 at 18:14
  • Also the installation of mosquitto is fine I think. If I just start it locally it works just fine. Only the bridge doesn't. It also works if i start mosquitto_sub and subscribe to test.mosquitto.org – nicoj Mar 17 '17 at 18:18

2 Answers2

1

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.

1

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.

Ben T
  • 4,656
  • 3
  • 22
  • 22