core: aiowithings.exceptions.WithingsConnectionError: Timeout occurred while connecting to Withings

The problem

Logger: homeassistant.components.withings
Source: helpers/update_coordinator.py:300
Integration: Withings (documentation, issues)
First occurred: 09:37:26 (1 occurrences)
Last logged: 09:37:26

Unexpected error fetching Withings measurements data: Timeout occurred while connecting to Withings
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiowithings/withings.py", line 105, in _request
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 574, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 911, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection
    transport, protocol = await self._create_connection_transport(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport
    await waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiowithings/withings.py", line 104, in _request
    async with asyncio.timeout(self.request_timeout):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/withings/coordinator.py", line 70, in _async_update_data
    return await self._internal_update_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/withings/coordinator.py", line 100, in _internal_update_data
    measurements = await self._client.get_measurement_in_period(startdate, now)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiowithings/withings.py", line 190, in get_measurement_in_period
    return await self._get_measurements(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiowithings/withings.py", line 166, in _get_measurements
    response = await self._request("measure", data=data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiowithings/withings.py", line 113, in _request
    raise WithingsConnectionError(msg) from exception
aiowithings.exceptions.WithingsConnectionError: Timeout occurred while connecting to Withings

What version of Home Assistant Core has the issue?

core-2024.1.2

What was the last working version of Home Assistant Core?

Around November or December 2023

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Withings

Link to integration documentation on our website

https://www.home-assistant.io/integrations/withings/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Happens every time I restart. The integration actually loads fine. I’m feeling like it’s actually an issue on the Withings side or we are timing out the request prematurely. It looks like there was a change in aiowithings which touched timouts around the time I started to see issues.

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 29 (28 by maintainers)

Most upvoted comments

I was chatting with Cody on discord today, and he had this error raised when subscribing webhooks. So when looking at the logs you would think it subscribed 5 webhooks (since one raised an error) but when manually calling the call to list all the webhooks, 6 were returned. So I think there’s also a bit of Withings trickery involved.

Afterwards Cody created a new Withings application and it dissapeared

Since I can consistently reproduce this one, I’m going to try to raise a PR later to catch and retry this error.