question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to Connect to MQTT broker on LAN

See original GitHub issue

Problem/Motivation

I’d like to be able to connect to Mosquitto MQTT broker running on my LAN.

Expected behavior

I have another Raspberry Pi 2 running Raspbian with the latest Node-RED installed, and it connects to my MQTT broker without issue, here’s my Node-RED log showing a working MQTT connection:

# RASPBIAN LOG #
3 Nov 01:07:20 - [info] Node-RED version: v0.19.5
3 Nov 01:07:20 - [info] Node.js  version: v8.12.0
3 Nov 01:07:20 - [info] Linux 4.9.35-v7+ arm LE
3 Nov 01:07:22 - [info] Loading palette nodes
global Settings { uib_globalSettings: { debug: false },
userDir: '/home/pi/.node-red',
httpNodeRoot: '/' }
3 Nov 01:07:32 - [info] Settings file  : /home/pi/.node-red/settings.js
3 Nov 01:07:32 - [info] Context store  : 'default' [module=memory]
3 Nov 01:07:32 - [info] User directory : /home/pi/.node-red
3 Nov 01:07:32 - [info] Server now running at http://127.0.0.1:1880/
3 Nov 01:07:32 - [info] Active project : ras_pi_node_red_flows
3 Nov 01:07:32 - [info] Flows file     : /home/pi/.node-red/projects/ras_pi_node_red_flows/flows_ras_pi.json
3 Nov 01:07:33 - [info] Starting flows
3 Nov 01:07:34 - [info] Started flows
3 Nov 01:07:35 - [info] [mqtt-broker:DS413 root] Connected to broker: mqtts://ds413.local:8883

[mqtt-broker:DS413 root] Connected to broker: mqtts://ds413.local:8883

I can send and recieve test messages over MQTT in Node-RED also.

Actual behavior

The Hass.IO Node-RED addon does not connect to the exact same MQTT server with the exact same settings the MQTT options in Node-RED, I copy/pasted the working flow and used the same credentials. Log:

# HASSIO LOG #
3 Nov 01:02:10 - [info] Node-RED version: v0.19.5
3 Nov 01:02:10 - [info] Node.js  version: v8.12.0
3 Nov 01:02:10 - [info] Linux 4.14.78-v7 arm LE
3 Nov 01:02:11 - [info] Loading palette nodes
3 Nov 01:02:17 - [info] Settings file  : /etc/node-red/config.js
3 Nov 01:02:17 - [info] Context store  : 'default' [module=memory]
3 Nov 01:02:17 - [info] User directory : /config/node-red/
3 Nov 01:02:17 - [warn] Projects disabled : editorTheme.projects.enabled=false
3 Nov 01:02:17 - [info] Flows file     : /config/node-red/flows.json
3 Nov 01:02:17 - [info] Server now running at http://127.0.0.1:1880/
3 Nov 01:02:17 - [info] Starting flows
3 Nov 01:02:17 - [info] Started flows
3 Nov 01:02:17 - [info] [server:Home Assistant] WebSocket Connected to http://hassio/homeassistant
3 Nov 01:02:43 - HA Auth - DevTesta authenticated
3 Nov 01:02:47 - [info] [mqtt-broker:DS413 root] Connection failed to broker: mqtts://ds413.local:8883

[mqtt-broker:DS413 root] Connection failed to broker: mqtts://ds413.local:8883

It looks like it doesn’t even try and connect to my broker, I checked the mosquitto logfile on ds413.local and it doesn’t even log a connection attempt from my hassio.local IP address.

Steps to reproduce

Try and connect to a MQTT host over Lan, maybe it’s because I’m using TLS? I’ll try another MQTT server without encryption or a public test server.

EDIT: I tried using MQTT server test.mosquitto.org:1883 wired up to a debug node, topic = “+” and it works great, it produces a lot of test messages, so it seems to be a issues with MQTT over LAN only.

Proposed changes

I’m not sure yet, I don’t have a solution yet. I’m guessing it’s a network issue, or maybe mDNS? What steps can I do to debug? Thanks

EDIT: My HASS.IO info:

Hostname hassio
System HassOS 1.12
Deployment production

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DeviousPenguincommented, Nov 3, 2018

Ok, thanks this does seem to be more of a Hass.IO issue, after more testing even the homeassistant container has the same nDNS issue. Thanks for pointing me in the right direction, hopefully with a little tinkering of Hass.IO I should be able to fix or workaround this issue.

1reaction
frenckcommented, Nov 3, 2018

that is (unfortunately) outside the scope of the add-on. The network is provided by Hass.io.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't connect to Mosquitto broker with local IP address
I can connect to this on the same machine using an MQTT client such as MQTTX when I specify localhost as the address....
Read more >
Cannot connect to MQTT broker on local network - General
There is no security on the broker and it is set up to accept anonymous connections.
Read more >
Unable to connect to MQTT broker in LAN - 273304
I have tried communicating with the LAN broker using mosquitto_pub with the host device and the IOT2040. The host was able to publish...
Read more >
Can't connect to mqtt broker - Stack Overflow
Locally, if I putty in to the RPi running the Mosquitto MQTT broker everything is OK. I can use the client commands (...
Read more >
Unable to connect to MQTT broker using Node-red & Local ...
Hi,. Main problem: Unable to connect to MQTT broker on another device within the same local network. Own observations:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found