OpenHab MQTT Gateway Error - Unable to connect to server



  • Using openHab 1.6.2 on Windows 7
    Mysensors 1.4
    Followed directions: http://www.mysensors.org/build/mqtt_gateway and also http://forum.mysensors.org/topic/303/mqtt-broker-gateway
    Using an arduino R3 and a W5100 Etherent Shield and NRF24L01 radio wired up just like the web page instructions. When starting openHab I see MQTT errors. Primarily: Unable to connect to server.
    Does anybody have any thoughts on what could be wrong? Attached full debig log. I have tried port 1883 and 1880.

    openhab.log



  • This may be an OpenHab problem. I don't know anything about MQTT but after downloading an MQTT client it appears it can connect where OpenHab cannot. From the MQTT client I can publish some data and see at least some output in the arduino serial console (not the same text).

    I can also see that the MQTT gateway (Mysensors code running on arduino with w5100) appears in my router and I can ping the IP.



  • Well I took a break from this and when I returned I realized my mistake. It is a bit embarrassing but I will explain so maybe it helps somebody else.

    openHAB would start and be unable to connect to the mysensor MQTT gateway (Broker). It would throw a timeout error.

    Using the MQTTLens chrome client I could publish mqtt messages and see some output in the serial monitor for the arduino.(Side note baud rate for the monitor must be 115200 to see real output). However I noticed I could never receive messages, only publish.

    That made me think the messages were getting to my arduno mqtt gateway but not leaving. I then looked at my router's port forwarding and sure enough I had it wrong. I had 1883 forwarding to the IP address of my gateway but on port 1883. Since the default mqtt port is 1883 I decided to change my listener port on the arduino. So in the MQTTGateway sketch I changed it to 1880. Then I changed my port forwarding to forward 1883 to my arduino IP on port 1880.

    Now all is working. I hope my mistake can help save somebody some time in the future.



  • One more update. The port forwarding was not a complete fix. The real culprit was my Asus RT-N66U router which has LAN-WAN firewall. When enabled it was allowing wan traffic to my gateway but not allowing a response from my gateway out to the controller.


Log in to reply
 

Suggested Topics

  • 22
  • 10
  • 132
  • 2
  • 5
  • 19

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts