michaelarnauts / cec-mqtt-bridge

A HDMI-CEC to MQTT bridge for connecting HDMI-CEC-devices to your Home Automation system.
150 stars 48 forks source link

Error on startup "Cannot assign requested address" #27

Open snhnry opened 5 years ago

snhnry commented 5 years ago

I'm trying to install the bridge on a raspberry pi 3 B+. I've tried it on Hassbian and Raspbian Buster with no luck. Currently trying to run it in a docker container (but have tried without docker) and I always get this message on startup:

Initialising CEC...
Initialising MQTT...
Traceback (most recent call last):
  File "bridge.py", line 360, in <module>
    mqtt_client.connect(config['mqtt']['broker'], int(config['mqtt']['port']), 60)
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 760, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 887, in reconnect
    sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
  File "/usr/local/lib/python3.6/socket.py", line 722, in create_connection
    raise err
  File "/usr/local/lib/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address

The docker command is docker run -d --device=/dev/vcsm --device=/dev/vchiq --restart unless-stopped cec-mqtt-bridge

My config is:

; MQTT broker configuration
;
[mqtt]
; Hostname of mqtt broker (required)
broker=192.168.1.34

; Name of your device (default=cec-ir-mqtt)
devicename=cec-ir-mqtt 

; Port to connect to (default=1883)
port=1883

; Use tls
;tls=0

; Username and password
user=*****
password=*****

; MQTT prefix to use
prefix=apartment/tv

;
; HDMI-CEC configuration
;
[cec]
; Enable CEC
enabled=1

; ID of CEC controller
id=1

; Port where the CEC-device is connected
port=RPI

; Devices to query (comma seperated, defaults to all devices)
;devices=0,2,3,4,5

;
; LIRC configuration
;
[ir]
; Enable LIRC
enabled=0

Other info: Running Mosquitto 1.5.7 successfully with various other clients connected

Very rarely I have received an error similar to "Cannot connect to CEC adapter", but 90% of the time it is the above traceback. Any help would be hugely appreciated, thanks.