Problems with embedded MQTT?

Getting this error:

“hbmqtt.broker.BrokerException: Broker instance can’t be started: an integer is required (got type str)”

From this config:

mqtt:
  embedded:
    listeners:
      default:
        max-connections: 50000
        type: tcp
         bind: 0.0.0.0:1883
    username: hass
    password: hass

Any one else seeing similar?

I getting this error:

"homeassistant.components.mqtt: Unable to start broker and auto-configure MQTT.
16-07-06 23:34:19 homeassistant.bootstrap: component mqtt failed to initialize
16-07-06 23:34:19 hbmqtt.broker: Broker startup failed: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 1883): only one usage of each socket address (protocol/network address/port) is normally permitted
16-07-06 23:34:19 homeassistant.components.mqtt.server: Error initializing MQTT server
Traceback (most recent call last):
  File "C:\Python34\lib\asyncio\base_events.py", line 905, in create_server
    sock.bind(sa)
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted"

This is my configuration:

mqtt:
  embedded:
     listeners:
        default:
          max-connections: 50000
          bind: 0.0.0.0:1883
          type: tcp

Hi,

As per the error looks like you’re trying to bind to a port already in use. Have you checked the netstat output?

Also any one have any idea why my config is getting evaluated as a string? Manually forcing values into the “broker.py” it looks like the service tries to rebind several times. The MQTT does run at this point even though an error is reported.

Any thoughts on the above behavior?

M.

I suspect ‘0.0.0.0:1883’ is the culprit. Have you tried using a basic config without bind, max-connections, etc?

I’ve tried minimizing the config down as much as possible with no joy. Previously that configuration worked. It’s like there’s something around the "split at ‘:’ " routine that needs addressing so the types don’t get mixed up. As before though even when I do assert the correct types straight into the variables other errors start to pop up. Looking at most configs it appears most people use an external broker so maybe this is a new issue?

When I minimize the configuration without bind then I getting this error:

"16-07-07 06:44:43 homeassistant.components.mqtt: Unable to start broker and auto-configure MQTT.
16-07-07 06:44:43 homeassistant.bootstrap: component mqtt failed to initialize
16-07-07 06:44:43 homeassistant.components.mqtt: Unable to start broker and auto-configure MQTT.
"

Gave up in the end and went back to using Mosquitto.

There seems to be some fundamental problems either in parsing the configuration or starting the embedded server. Even in the default unconfigured state generate_config(hass, passwd): from server.py should generate a working config but this bails out as well.

Finally, I run hbmqtt manually, then using this config:

mqtt:
broker: 127.0.0.1
port: 1883
client_id: home-assistant-1
keepalive: 60

It working for me!

Thanks for all ideal!

Hi I am having the same issue. Has anyone found a solution to this issue yet?

I am running Home Assistant on Docker image 0.28.2

Here is my log entry:

16-09-21 09:35:54 homeassistant.components.mqtt.server: Error initializing MQTT server
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/hbmqtt/broker.py", line 257, in start
    loop=self._loop)
  File "/usr/local/lib/python3.4/asyncio/streams.py", line 116, in start_server
    return (yield from loop.create_server(factory, host, port, **kwds))
  File "/usr/local/lib/python3.4/asyncio/base_events.py", line 946, in create_server
    sock.bind(sa)
TypeError: an integer is required (got type str)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/mqtt/server.py", line 53, in start
    loop.run_until_complete(start_server)
  File "/usr/local/lib/python3.4/asyncio/base_events.py", line 361, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.4/asyncio/base_events.py", line 331, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.4/asyncio/base_events.py", line 1295, in _run_once
    handle._run()
  File "/usr/local/lib/python3.4/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/usr/local/lib/python3.4/asyncio/tasks.py", line 308, in _wakeup
    self._step()
  File "/usr/local/lib/python3.4/asyncio/tasks.py", line 240, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/components/mqtt/server.py", line 24, in broker_coro
    yield from broker.start()
  File "/usr/local/lib/python3.4/site-packages/hbmqtt/broker.py", line 279, in start
    raise BrokerException("Broker instance can't be started: %s" % e)
hbmqtt.broker.BrokerException: Broker instance can't be started: an integer is required (got type str)
16-09-21 09:35:54 homeassistant.components.mqtt: Unable to start broker and auto-configure MQTT.

What is your configuration?

See this thread for possible solutions.

Hi,

Same problem here. I used the all in one installer (0.39.3) on a fresh Raspbian install.

mqtt:
  embedded:

Results in:

17-03-09 00:07:44 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

Tried all of the fixes on the links above, including setting the http host to 127.0.0.1, moving the embedded port to 1888. But the one thing I have noticed is that 0.0.0.0:1883 is already in use by Mosquitto - this is not something I’ve installed, but I guess must be in by default.

pi@homeassistant:/home/homeassistant/.homeassistant $ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN      800/python3
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      489/mosquitto
tcp        0      0 0.0.0.0:9001            0.0.0.0:*               LISTEN      489/mosquitto
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      800/python3
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      704/sshd
tcp6       0      0 :::1883                 :::*                    LISTEN      489/mosquitto
tcp6       0      0 :::22                   :::*                    LISTEN      704/sshd
udp        0      0 0.0.0.0:68              0.0.0.0:*                           703/dhcpcd
udp        0      0 10.10.1.102:123         0.0.0.0:*                           727/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           727/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           727/ntpd
udp        0      0 0.0.0.0:38045           0.0.0.0:*                           405/avahi-daemon: r
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           405/avahi-daemon: r
udp6       0      0 fe80::f338:3dfe:d5e:123 :::*                                727/ntpd
udp6       0      0 ::1:123                 :::*                                727/ntpd
udp6       0      0 :::123                  :::*                                727/ntpd
udp6       0      0 :::5353                 :::*                                405/avahi-daemon: r
udp6       0      0 :::49958                :::*                                405/avahi-daemon:

What I’m completely stuck with is how to stop mosquitto using it? I find mosquitto_pub and mosquitto_sub commands quite useful, which again, must in either HA or Raspbian by default.

Thanks for any advice.

Kind of fixed it.

Rather than getting rid of mosquitto, I decided to use it instead of the embedded one.

So, for my simple setup it meant editting mosquitto.conf and setting

allow_anonymous true

and in configuration.yaml, a very simple:

mqtt:
  broker: 127.0.0.1

I know all this is simple stuff for many, but I’m working everything out from scratch and this is something I wasted a lot of time on.