synesthesiam / homeassistant-satellite

Streaming audio satellite for Home Assistant
MIT License
186 stars 22 forks source link

Server disconnect loop #22

Closed jarhed closed 10 months ago

jarhed commented 11 months ago

Hey there, thanks for your hard work. This is the last piece of the puzzle for me automated house.

I'm getting the following looping, it connects to HA but then immediately disconnects...any ideas?

Oct 15 13:30:56 eggbert-ears run[1910]: ERROR:__main__:Unexpected error
Oct 15 13:30:56 eggbert-ears run[1910]: Traceback (most recent call last):
Oct 15 13:30:56 eggbert-ears run[1910]:   File "/home/eggbert/homeassistant-satellite/homeassistant_satellite/__main__.py", line 200, in main
Oct 15 13:30:56 eggbert-ears run[1910]:     async for _timestamp, event_type, event_data in stream(
Oct 15 13:30:56 eggbert-ears run[1910]:   File "/home/eggbert/homeassistant-satellite/homeassistant_satellite/remote.py", line 28, in stream
Oct 15 13:30:56 eggbert-ears run[1910]:     async with session.ws_connect(url) as websocket:
Oct 15 13:30:56 eggbert-ears run[1910]:   File "/home/eggbert/homeassistant-satellite/.venv/lib/python3.9/site-packages/aiohttp/client.py", line 1141, in __aenter__
Oct 15 13:30:56 eggbert-ears run[1910]:     self._resp = await self._coro
Oct 15 13:30:56 eggbert-ears run[1910]:   File "/home/eggbert/homeassistant-satellite/.venv/lib/python3.9/site-packages/aiohttp/client.py", line 779, in _ws_connect
Oct 15 13:30:56 eggbert-ears run[1910]:     resp = await self.request(
Oct 15 13:30:56 eggbert-ears run[1910]:   File "/home/eggbert/homeassistant-satellite/.venv/lib/python3.9/site-packages/aiohttp/client.py", line 560, in _request
Oct 15 13:30:56 eggbert-ears run[1910]:     await resp.start(conn)
Oct 15 13:30:56 eggbert-ears run[1910]:   File "/home/eggbert/homeassistant-satellite/.venv/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 899, in start
Oct 15 13:30:56 eggbert-ears run[1910]:     message, payload = await protocol.read()  # type: ignore[union-attr]
Oct 15 13:30:56 eggbert-ears run[1910]:   File "/home/eggbert/homeassistant-satellite/.venv/lib/python3.9/site-packages/aiohttp/streams.py", line 616, in read
Oct 15 13:30:56 eggbert-ears run[1910]:     await self._waiter
Oct 15 13:30:56 eggbert-ears run[1910]: aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected
jarhed commented 11 months ago

Hey, sorted it. My server is SSL so had to point the satellite at the hostname, not the IP.

jclsn commented 11 months ago

Same issue here without SSL. I have tried IP and hostname and the https proxy server name with --protocol https. Always the same error

vhsdream commented 11 months ago

Have you tried also specifying the port with --port? I believe it defaults to 8123; for one of my tests with a device on a different VLAN I changed the host to the FQDN, made --protocol to https and then had to also do --port 443 to get it to connect.

jclsn commented 11 months ago

@vhsdream No, but I tried printing the url in the script

ws://homeassistant:8123/api/websocket

which seems to look fine.

Port 443 is https. I can connect fine to Home Assistant using http. I think that the my HA installation has an issue. It is also displays a weird hostname since the last update. Like a7f8s7f9a9sf9a98-hap or something. Unfortunately I don't have experience with websockets.

jclsn commented 10 months ago

Got it working. Turns out my Homeassistant wasn't available via http. I was wrong about that.