core: HTTP(s) webserver not starting

I’m runing hass-emulated-hue in a standalone docker (not as add-on). HUE Bridge cannot be found on the network. Also port 80 or 443 or not responding on the IP of the docker container.

Steps to Reproduce

Start the docker image:

docker run --name=hass-emulated-hue -hostname=hass-emulated-hue -e TZ=Europe/Amsterdam -e \
  HASS_URL=https://homeassistant.example.com -e HASS_TOKEN=*** -e VERBOSE=true --network lan-static --ip x.x.x.x \   -v hass-emulated-hue-config:/config/.emulated-hue ghcr.io/hass-emulated-hue/core:latest

Expected behavior

HUE Bridge is discoverable on the network. Also ports 80 and/or 443 should at least make a TCP connection. While browsing other issues, I noticed that the logs should contain lines like these:

emulated_hue.api -- Started HTTP webserver on port 80
emulated_hue.api -- Started HTTPS webserver on port 443

but those are not in my logs.

Logs

Output from docker container:

[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-set-vars.sh: executing...
[21:31:30] INFO: Starting Emulated Hue...
[cont-init.d] 00-set-vars.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
2022-06-08 21:31:30,501 DEBUG emulated_hue.utils -- Loading /root/.emulated_hue/emulated_hue.json failed: [Errno 2] No such file or directory: '/root/.emulated_hue/emulated_hue.json'
2022-06-08 21:31:30,507 INFO  emulated_hue.config -- Auto detected listen IP address is x.x.x.x
2022-06-08 21:31:30,519 DEBUG getmac -- Raw MAC found: None
2022-06-08 21:31:30,522 DEBUG getmac -- Raw MAC found: 00:50:56:ba:6b:8a

2022-06-08 21:31:30,525 DEBUG aiorun -- Entering run()
2022-06-08 21:31:30,537 DEBUG aiorun -- Creating default executor
2022-06-08 21:31:30,561 INFO  hass_client -- Connected to Home Assistant wss (version 2022.6.4)

Also I see a log entry in Home Assistant when the container starts:

[140174100621440] Client unable to keep up with pending messages. Stayed over 512 for 5 seconds

Hardware Info:

  • Architecture: x86
  • Addon version: ghcr.io/hass-emulated-hue/core:latest
  • OS: Docker: VMWare VCH, HASS: Supervised
  • Hardware : PC/Server

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

I’ve digged a bit deeper (and found a conclusion):

File emualted_hue/controllers/__init__.py: I’ve added debug print around relevant await:

    print('HAC: connect')
    await ctl.controller_hass.connect()
    print('HAC: connected')

I see this:

HAC: connect
2023-02-14 21:09:37,262 INFO  hass_client -- Connected to Home Assistant wss (version 2023.2.4)

To, it seems that HomeAssistantController.connect awaits indefinitely. This method is inherited from HomeAssistantClient. At the moment of the indefinite await, we are somewhere in https://github.com/hass-emulated-hue/python-hass-client/blob/0.1.5/hass_client/client.py#L288-L293 :

  • The self._loop.create_task call is probably innocent, as it shouldn’t block.
  • The self.send_command might be innocent, although it is not that easy.
  • The self._request_full_state() call requests various information. Maybe it requests some information it cannot obtain.

So, I’ve started sniffing the communication between HA and HEH:

ssh user@host 'sudo dumpcap -P -w - -i lo -f "tcp port 8123"' | qvm-run-vm @dispvm 'wireshark -k -i -'

client: {"type":"subscribe_events","id":1}
server: {"id":1,"type":"result","success":false,"error":{"code":"unauthorized","message":"Unauthorized"}}

Conclusion: At this point, I can probably conclude that HEH requires admin token. When it gets user token, it doesn’t report the issue properly and hangs on startup.

@meden The image uses host networking which allows direct access to host ports. You will therefore not see any port mappings. The ports uses can be configured in the config options.

@fjgalesloot I’m not entirely sure what could be happening here. Can you list the steps that you took to reproduce this from a clean home assistant install? I am unable to reproduce this.