Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Frequent errors about "Address in use" #21

Open
lyricnz opened this issue Feb 7, 2023 · 5 comments
Open

Frequent errors about "Address in use" #21

lyricnz opened this issue Feb 7, 2023 · 5 comments

Comments

@lyricnz
Copy link
Owner

lyricnz commented Feb 7, 2023

Version of the custom_component

0.1.1

Configuration

Three switches configured. It's likely the issue is cause by concurrent queries, and listening to a single network port.

Describe the bug

Errors in the HA logs

This error originated from a custom integration.

Logger: tplink_ess_lib
Source: custom_components/tplink_ess/api.py:28
Integration: TPLink ESS (documentation, issues)
First occurred: 6 February 2023 at 13:40:36 (84 occurrences)
Last logged: 13:44:22

Problems with network interface: [Errno 98] Address in use

also (perhaps related)

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/tplink_ess/binary_sensor.py:120
Integration: TPLink ESS (documentation, issues)
First occurred: 12:34:42 (1 occurrences)
Last logged: 12:34:42

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 330, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 135, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 390, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 566, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 606, in _async_write_ha_state
    available = self.available  # only call self.available once per update cycle
  File "/config/custom_components/tplink_ess/binary_sensor.py", line 120, in available
    or self._key in self.coordinator.data.get("hostname")
TypeError: argument of type 'NoneType' is not iterable

Debug log


Add your logs here.

@lyricnz lyricnz changed the title Frequent errors about Frequent errors about "Address in use" Feb 7, 2023
@firstof9
Copy link
Collaborator

firstof9 commented Feb 7, 2023

Problems with network interface: [Errno 98] Address in use

This error is coming from the library.

Try changing the version of the library in your manifest.json to 0.4.4 from 0.4.3 and see if the issue persists.

@lyricnz
Copy link
Owner Author

lyricnz commented Feb 7, 2023

Agree the the conflict is likely caused by concurrent use of the query (which requires binding to a static port) but (a) HA should synchronize/not do this concurrently, (b) should handle errors from library - if that's what's causing the second error.

Will bump the verison.

@lyricnz
Copy link
Owner Author

lyricnz commented Feb 7, 2023

Still get error - see firstof9/tplink-ess-lib#35 (comment)

@firstof9
Copy link
Collaborator

firstof9 commented Feb 8, 2023

Just as an FYI, I was getting "address in use" messages on my single switch, this fix solved it for my specific use case.

@lyricnz
Copy link
Owner Author

lyricnz commented May 7, 2023

Will make a PR to the underlying library to make a single UDP listener, then reuse it for all the queries. This should make it fully asyncio and more parallelisable. And stop this error (which happens when multiple request-responses overlap)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants