IDmedia / hass-unraid

This Docker container parses and forwards all WebSocket messages from your Unraid server to Home Assistant using the MQTT protocol
115 stars 5 forks source link

isn't a valid URI: scheme isn't ws or wss #2

Closed stu1811 closed 8 months ago

stu1811 commented 8 months ago

Here is a snippet from the docker logs. I'm running unraid 6.12.6.

2024-03-28 00:58:30,479 [ERROR] [Tower] Failed to connect to unraid due to an exception...
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 658, in __await_impl__
    await protocol.handshake(
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 326, in handshake
    raise RedirectHandshake(response_headers["Location"])
websockets.exceptions.RedirectHandshake: redirect to http://192.168.42.201/login

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/main.py", line 206, in ws_connect
    async with websockets.connect(websocket_url, subprotocols=subprotocols, extra_headers=headers) as websocket:
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 633, in __aenter__
    return await self
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 650, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 668, in __await_impl__
    self.handle_redirect(exc.uri)
  File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 555, in handle_redirect
    new_wsuri = parse_uri(new_uri)
  File "/usr/local/lib/python3.9/site-packages/websockets/uri.py", line 77, in parse_uri
    raise exceptions.InvalidURI(uri, "scheme isn't ws or wss")
websockets.exceptions.InvalidURI: http://192.168.42.201/login isn't a valid URI: scheme isn't ws or wss
2024-03-28 00:58:30,480 [ERROR] [Tower] Last message received:
2024-03-28 00:58:30,480 [ERROR] [Tower] 

Sanitized config file

unraid:
  - name: Tower
    host: 192.168.42.201
    port: 80
    ssl: false
    username: root
    password: <PASSWORDOFDOOM>
    scan_interval: 30

mqtt:
  host: 192.168.42.200
  port: 1883
  username: <MQTT_USERNAME>
  password: <MYSECRETPW>
IDmedia commented 8 months ago

Use http://192.168.42.201 or https://192.168.42.201

It's used for determining if ws or wss is used in order to connect to the web socket.

stu1811 commented 8 months ago

I updated the config file per your suggestion to host: http://192.168.42.201

Edit: My unraid password uses special character. I tried putting quotes around the field but it didn't help.

Edit2: I looked at the code and found the error. ssl: false should be ssl: False in your config example.

2024-03-28 11:09:41,540 [INFO] [Tower] Connecting to mqtt server...
2024-03-28 11:09:41,543 [INFO] [Tower] Successfully connected to mqtt server
2024-03-28 11:09:41,544 [INFO] [Tower] Connecting to unraid...
2024-03-28 11:09:41,795 [ERROR] [Tower] Failed to connect to unraid due to a timeout or connection issue...
2024-03-28 11:10:11,797 [INFO] [Tower] Connecting to unraid...
2024-03-28 11:10:12,000 [ERROR] [Tower] Failed to connect to unraid due to a timeout or connection issue...
Traceback (most recent call last):
  File "/app/main.py", line 286, in <module>
    loop.run_forever()
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 601, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1869, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/local/lib/python3.9/selectors.py", line 469, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
  File "/app/utils.py", line 29, in handle_sigterm
    raise KeyboardInterrupt()
KeyboardInterrupt
2024-03-28 11:11:23,571 [INFO] [Tower] Connecting to mqtt server...
2024-03-28 11:11:23,578 [INFO] [Tower] Successfully connected to mqtt server
2024-03-28 11:11:23,578 [INFO] [Tower] Connecting to unraid...
2024-03-28 11:11:23,633 [ERROR] [Tower] Failed to connect to unraid due to a timeout or connection issue...
Shiroe93 commented 3 months ago

I updated the config file per your suggestion to host: http://192.168.42.201

Edit: My unraid password uses special character. I tried putting quotes around the field but it didn't help.

Edit2: I looked at the code and found the error. ssl: false should be ssl: False in your config example.

2024-03-28 11:09:41,540 [INFO] [Tower] Connecting to mqtt server...
2024-03-28 11:09:41,543 [INFO] [Tower] Successfully connected to mqtt server
2024-03-28 11:09:41,544 [INFO] [Tower] Connecting to unraid...
2024-03-28 11:09:41,795 [ERROR] [Tower] Failed to connect to unraid due to a timeout or connection issue...
2024-03-28 11:10:11,797 [INFO] [Tower] Connecting to unraid...
2024-03-28 11:10:12,000 [ERROR] [Tower] Failed to connect to unraid due to a timeout or connection issue...
Traceback (most recent call last):
  File "/app/main.py", line 286, in <module>
    loop.run_forever()
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 601, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1869, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/local/lib/python3.9/selectors.py", line 469, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
  File "/app/utils.py", line 29, in handle_sigterm
    raise KeyboardInterrupt()
KeyboardInterrupt
2024-03-28 11:11:23,571 [INFO] [Tower] Connecting to mqtt server...
2024-03-28 11:11:23,578 [INFO] [Tower] Successfully connected to mqtt server
2024-03-28 11:11:23,578 [INFO] [Tower] Connecting to unraid...
2024-03-28 11:11:23,633 [ERROR] [Tower] Failed to connect to unraid due to a timeout or connection issue...

Same issue even after implementing all the things suggested to you Has something changed?