tydom2mqtt icon indicating copy to clipboard operation
tydom2mqtt copied to clipboard

Server rejected WebSocket connection: HTTP 401

Open Yacchos opened this issue 1 year ago • 3 comments

Hi there, I have the same connection problem every time my tydom box restarts (electrical shutdown for exemple...). The connection to the mqtt broker works fine, the connection to the tydom is rejected. And after a long long time (why I don't know), every things works fine as before the restart. Someone has an idea? Here is my log :

2023-05-22 21:17:09,271 - Starting tydom2mqtt 2023-05-22 21:17:09,272 - Hassio environment detected: loading configuration from /data/options.json 2023-05-22 21:17:09,273 - Validating configuration ({ "deltadore_login": null, "deltadore_password": "", "log_level": "INFO", "mqtt_host": "192.168.1.40", "mqtt_password": "**", "mqtt_port": 1883, "mqtt_ssl": false, "mqtt_user": "mqtt", "tydom_alarm_home_zone": 1, "tydom_alarm_night_zone": 2, "tydom_alarm_pin": "", "tydom_ip": "192.168.1.14", "tydom_mac": "001A25", "tydom_password": "*************" } 2023-05-22 21:17:09,273 - The configuration is valid 2023-05-22 21:17:09,273 - tydom.TydomClient - INFO - Configure local mode (192.168.1.14) 2023-05-22 21:17:09,278 - mqtt.MqttClient - INFO - Connecting to mqtt broker (host=192.168.1.40, port=1883, user=mqtt, ssl=False) 2023-05-22 21:17:09,279 - tydom.TydomClient - INFO - Connecting to tydom 2023-05-22 21:17:11,816 - mqtt.MqttClient - INFO - Connected to mqtt broker 2023-05-22 21:17:14,327 - tydom.TydomClient - ERROR - Exception when trying to connect with websocket (server rejected WebSocket connection: HTTP 401) 2023-05-22 21:17:14,337 - asyncio - ERROR - Task exception was never retrieved future: <Task finished name='Task-2' coro=<listen_tydom() done, defined at /app/main.py:41> exception=SystemExit(1)> Traceback (most recent call last): File "/app/tydom/TydomClient.py", line 170, in connect self.connection = await websockets.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 655, in await_impl_timeout return await self.await_impl() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 662, in await_impl await protocol.handshake( File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 329, in handshake raise InvalidStatusCode(status_code, response_headers) websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 401 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/base_events.py", line 607, in run_forever self._run_once() File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once handle._run() File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/app/main.py", line 44, in listen_tydom await tydom_client.connect() File "/app/tydom/TydomClient.py", line 181, in connect sys.exit(1) SystemExit: 1 2023-05-22 21:17:14,350 - asyncio - ERROR - Task was destroyed but it is pending! task: <Task pending name='Task-3' coro=<Client._resend_qos_messages() running at /usr/local/lib/python3.11/site-packages/gmqtt/client.py:181> wait_for=<Future pending cb=[Task.task_wakeup()]>> 2023-05-22 21:17:14,351 - asyncio - ERROR - Task was destroyed but it is pending! task: <Task pending name='Task-4' coro=<MQTTProtocol._read_loop() running at /usr/local/lib/python3.11/site-packages/gmqtt/mqtt/protocol.py:211> wait_for=<Future pending cb=[Task.task_wakeup()]>> 2023-05-22 21:17:14,351 - asyncio - ERROR - Task was destroyed but it is pending! task: <Task pending name='Task-140' coro=<WebSocketCommonProtocol.close_connection() running at /usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py:1338> wait_for=<Future finished result=None>>

Yacchos avatar May 22 '23 19:05 Yacchos

I am experiencing the same issue after Delta Dore informed me on the App that the tydom hub has to be updated. Now the tydom2mqqt logs show:

2023-06-02 15:38:04,216 - The configuration is valid 2023-06-02 15:38:04,218 - tydom.TydomClient - INFO - Configure local mode (192.168.1.10) 2023-06-02 15:38:04,253 - mqtt.MqttClient - INFO - Connecting to mqtt broker (host=core-mosquitto, port=1883, user=mqtt, ssl=False) 2023-06-02 15:38:04,287 - tydom.TydomClient - INFO - Connecting to tydom 2023-06-02 15:38:05,701 - mqtt.MqttClient - INFO - Connected to mqtt broker 2023-06-02 15:38:06,888 - tydom.TydomClient - ERROR - Exception when trying to connect with websocket (server rejected WebSocket connection: HTTP 401) 2023-06-02 15:38:06,957 - asyncio - ERROR - Task exception was never retrieved future: <Task finished name='Task-2' coro=<listen_tydom() done, defined at /app/main.py:41> exception=SystemExit(1)> Traceback (most recent call last): File "/app/tydom/TydomClient.py", line 170, in connect self.connection = await websockets.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 655, in await_impl_timeout return await self.await_impl() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 662, in await_impl await protocol.handshake( File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 329, in handshake raise InvalidStatusCode(status_code, response_headers) websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 401 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/base_events.py", line 607, in run_forever self._run_once() File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once handle._run() File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/app/main.py", line 44, in listen_tydom await tydom_client.connect() File "/app/tydom/TydomClient.py", line 181, in connect sys.exit(1) SystemExit: 1 2023-06-02 15:38:07,056 - asyncio - ERROR - Task was destroyed but it is pending! task: <Task pending name='Task-3' coro=<Client._resend_qos_messages() running at /usr/local/lib/python3.11/site-packages/gmqtt/client.py:181> wait_for=<Future pending cb=[Task.task_wakeup()]>> 2023-06-02 15:38:07,061 - asyncio - ERROR - Task was destroyed but it is pending! task: <Task pending name='Task-4' coro=<MQTTProtocol._read_loop() running at /usr/local/lib/python3.11/site-packages/gmqtt/mqtt/protocol.py:211> wait_for=<Future pending cb=[Task.task_wakeup()]>> 2023-06-02 15:38:07,063 - asyncio - ERROR - Task was destroyed but it is pending! task: <Task pending name='Task-210' coro=<WebSocketCommonProtocol.close_connection() running at /usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py:1338> wait_for=<Future finished result=None>>

gergyverjux avatar Jun 02 '23 13:06 gergyverjux

and the tydom hub is blinking green & red

gergyverjux avatar Jun 02 '23 13:06 gergyverjux

I suspect I need to do a password reset on the tydom hub. Will try and see if it solves the issue. EDIT - Indeed, a password reset solved the issue - requires the older 3+ version of the app

gergyverjux avatar Jun 02 '23 19:06 gergyverjux