Problem starting embedded MQTT broker

Same error with -u user

I believe the user should be homeassistant as per https://home-assistant.io/docs/mqtt/broker/#embedded-broker

If you have mosquito running and try to start the internal broker, they both use the same port, and so this error occurs. You normally only need one broker for your network.

Yes this is the problem, however I have not started a mosquitto broker independently.
To be sure I run:

pi@hassbian:~ $ sudo /etc/init.d/mosquitto stop
[ ok ] Stopping mosquitto (via systemctl): mosquitto.service.

Now restart pi to restart HASSBIAN. Get in log the same info:

17-04-23 06:35:25 DEBUG (MainThread) [hbmqtt.broker.plugins] Loading plugins for namespace hbmqtt.broker.plugins
17-04-23 06:35:26 DEBUG (MainThread) [hbmqtt.broker] Broker starting
17-04-23 06:35:26 ERROR (MainThread) [hbmqtt.broker] Broker startup failed: [Errno 98] error while attempting to bind on address ('0.0.0.0', 1883): address already in use
17-04-23 06:35:26 ERROR (MainThread) [homeassistant.components.mqtt.server] Error initializing MQTT server
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/base_events.py", line 757, in create_server
    sock.bind(sa)
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/hbmqtt/broker.py", line 270, in start
    loop=self._loop)
  File "/usr/lib/python3.4/asyncio/streams.py", line 101, in start_server
    return (yield from loop.create_server(factory, host, port, **kwds))
  File "/usr/lib/python3.4/asyncio/base_events.py", line 761, in create_server
    % (sa, err.strerror.lower()))
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 1883): address already in use

So my question is what is starting the conflicting broker, since I am not doing it…?

Solution:

OK so I ran the HASSBIAN script https://github.com/home-assistant/hassbian-scripts#install-mosquitto-install_mosquitto

And in configuration.yaml added the mqtt broker as per https://home-assistant.io/docs/mqtt/broker/#run-your-own pointing to the IP of my HASSBIAN pi, and everything runs fine. I am unsure why this script is necessary if there is an embedded mqtt broker however…?

The internal broker is limited in its capabilities.

How can I tell if the embedded MQTT is running? I have 0.43.1 installed on a server running Ubuntu 16.04 and I installed via Virtual Environment.

When I run “sudo /etc/init.d/mosquitto status” I get:

sudo /etc/init.d/mosquitto status
sudo: /etc/init.d/mosquitto: command not found

And when I navigate to /etc/init.d there is no “mosquitto”

Do I need to install it? I thought embedded meant it was already there.

I am trying to run:

Mosquito is a stand alone, popular MQTT server. It is not the same as the embedded HASS broker. It needs to be installed.

Okay, thanks. I guess I misunderstood this thread.

I recall it not being the most straight forward thing when I was starting out either :slight_smile:

Mosquitto is worth your time vs the HASS broker though, IMHO.

I went back to cloud (had it for something way back) but still having issues. I can’t remember if I ever had it working. On a side note, I did get WallPanel installed on a Kindle Fire Tablet. So once I get mqtt figured out I’ll be in business.

1 Like

ahhh I think have this problem, how to stop mosquitto from running in boot?

I think if yoiu add
mqtt:
broker:

it will use mqtt, if you take out broker: it will use the embedded (but mosquitto also running on same port).

my goal is to use ssl/tls for a mqtt (mosquitto or embedded) how to do?

Disable it in whatever startup system your platform is using. For example, if you’re using systemd, then systemctl disable mosquitto

I have no idea which one I have. I installed a clean hassbian 1.1 image

how to check if I have this?

Hassbian is Raspbian based, which uses systemd.

thanks. Do I have to modify the file? Where is it?

Just run, as root (so, prefix with sudo if you’re not already root):

systemctl disable mosquitto

you mean one time only, after the next reboot will not start again?