2017-06-18 12:16:59 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", line 187, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py", line 377, in async_setup
success = yield from hass.data[DATA_MQTT].async_connect()
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py", line 487, in async_connect
self._mqttc.connect, self.broker, self.port, self.keepalive)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/deps/paho/mqtt/client.py", line 700, in connect
return self.reconnect()
File "/home/homeassistant/.homeassistant/deps/paho/mqtt/client.py", line 822, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python3.4/socket.py", line 509, in create_connection
raise err
File "/usr/lib/python3.4/socket.py", line 500, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
â—Ź \x2bl.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
pi@pi:~ $ sudo systemctl start mosquitto
pi@pi:~ $ sudo systemctl status mosquitto +l
â—Ź mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; disabled)
Active: active (running) since Mon 2017-06-19 23:29:10 EDT; 1s ago
Docs: man:mosquitto(8) https://mosquitto.org/
Main PID: 1894 (mosquitto)
CGroup: /system.slice/mosquitto.service
└─1894 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Jun 19 23:29:10 pi systemd[1]: Started Mosquitto MQTT Broker.
Jun 19 23:29:10 pi mosquitto[1894]: 1497929350: mosquitto version 1.4.12 (build date Thu, 25 May 2017 22:38:16 +0100) starting
Jun 19 23:29:10 pi mosquitto[1894]: 1497929350: Config loaded from /etc/mosquitto/mosquitto.conf.
Jun 19 23:29:10 pi mosquitto[1894]: 1497929350: Opening websockets listen socket on port 9001.
Jun 19 23:29:10 pi mosquitto[1894]: 1497929350: Opening ipv4 listen socket on port 1883.
Jun 19 23:29:10 pi mosquitto[1894]: 1497929350: Opening ipv6 listen socket on port 1883.
â—Ź \x2bl.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Starting it manually solve the issue, but it won’t start after a reboot.
2017-06-20 20:15:52 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", line 187, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py", line 364, in async_setup
will_message, birth_message, tls_version)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py", line 440, in __init__
proto = mqtt.MQTTv311
AttributeError: 'module' object has no attribute 'MQTTv311'
i was able to get mosquitto to run at start up by adding mosquitto -d to etc/rc.local
not sure why it stopped in the first place or why reinstalling mosquitto didnt fix it. may have something to do with being on hassbian running sudo apt-get update and upgrade then updating to the new release all in about an hour of each other. ran absolute havoc on my mqtt switches and sensors though.
I saw this in one forum but couldn’t find the link again. Got it working by below method if the service is not starting. You can try -
sudo update-rc.d mosquitto remove
sudo nano /etc/systemd/system/mosquitto.service
I tried the solution proposed by Claudio but still get this error
pi@hassbian:~ $ sudo mosquitto -v
1498377253: mosquitto version 1.3.4 (build date 2014-08-22 06:10:51+0000) starting
1498377253: Using default config.
1498377253: Opening ipv4 listen socket on port 1883.
1498377253: Error: Address already in use
pi@hassbian:~ $
Tried with netstat to find any other process on port 1883, but it did not show me any.
Any idea how to solve this?