Hi,
if there is a temporary problem in the network and refreshing the access token fails, the process to connect the websocket connection goes into an endless loop always using the expired token which fails.
The logs look like this:
[custom_components.mbapi2020.oauth] Start async_get_cached_token()
[custom_components.mbapi2020.oauth] custom_components.mbapi2020.oauth token expired -> start refresh
[custom_components.mbapi2020.oauth] Start async_refresh_access_token() with refresh_token
[custom_components.mbapi2020.oauth] ClientError requesting data from https://id.mercedes-benz.com/as/token.oauth2: Cannot connect to host id.mercedes-benz.com:443 ssl:True [Try again]
[custom_components.mbapi2020.websocket] Connecting to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws
[custom_components.mbapi2020.websocket] Could not connect to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws, retry in 10 seconds...
[custom_components.mbapi2020.websocket] Cannot connect to host websocket.emea-prod.mobilesdk.mercedes-benz.com:443 ssl:default [Try again]
[custom_components.mbapi2020.websocket] Connecting to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws
[custom_components.mbapi2020.websocket] Could not connect to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws, retry in 10 seconds...
This is because in async_get_cached_token a client error is ignored and the old token is returned. Afterwards the websocket async_connect enters an endless retry loop without ever refreshing updating the headers to use.
It seems like my network is not perfectly stable, so this happens from time to time and I have to restart the integration.
Hi, if there is a temporary problem in the network and refreshing the access token fails, the process to connect the websocket connection goes into an endless loop always using the expired token which fails. The logs look like this: [custom_components.mbapi2020.oauth] Start async_get_cached_token() [custom_components.mbapi2020.oauth] custom_components.mbapi2020.oauth token expired -> start refresh [custom_components.mbapi2020.oauth] Start async_refresh_access_token() with refresh_token [custom_components.mbapi2020.oauth] ClientError requesting data from https://id.mercedes-benz.com/as/token.oauth2: Cannot connect to host id.mercedes-benz.com:443 ssl:True [Try again] [custom_components.mbapi2020.websocket] Connecting to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws [custom_components.mbapi2020.websocket] Could not connect to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws, retry in 10 seconds... [custom_components.mbapi2020.websocket] Cannot connect to host websocket.emea-prod.mobilesdk.mercedes-benz.com:443 ssl:default [Try again] [custom_components.mbapi2020.websocket] Connecting to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws [custom_components.mbapi2020.websocket] Could not connect to wss://websocket.emea-prod.mobilesdk.mercedes-benz.com/ws, retry in 10 seconds...
This is because in async_get_cached_token a client error is ignored and the old token is returned. Afterwards the websocket async_connect enters an endless retry loop without ever refreshing updating the headers to use.
It seems like my network is not perfectly stable, so this happens from time to time and I have to restart the integration.