travisghansen / hass-opnsense

OPNsense integration with Home Assistant
194 stars 25 forks source link

Timeout Error #83

Closed gotschi closed 1 year ago

gotschi commented 1 year ago

No idea why or how but I think this is related to the device tracker feature of this integration, I track a lot of devices with this component.

Thank you

2023-05-02 18:29:30.691 ERROR (SyncWorker_23) [custom_components.opnsense.pyopnsense] Unexpected get_arp_table error err=TimeoutError('The read operation timed out'), type(err)=<class 'TimeoutError'>
2023-05-02 18:29:30.694 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 241, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/opnsense/config_flow.py", line 197, in async_step_init
    return await self.async_step_device_tracker()
  File "/config/custom_components/opnsense/config_flow.py", line 239, in async_step_device_tracker
    arp_table := await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 101, in inner
    raise err
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 98, in inner
    return func(*args, **kwargs)
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 586, in get_arp_table
    response = self._exec_php(script)
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 88, in inner
    response = func(*args, **kwargs)
  File "/config/custom_components/opnsense/pyopnsense/__init__.py", line 131, in _exec_php
    response = self._get_proxy().opnsense.exec_php(script)
  File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1122, in __call__
    return self.__send(self.__name, args)
  File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1464, in __request
    response = self.__transport.request(
  File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1166, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/local/lib/python3.10/xmlrpc/client.py", line 1179, in single_request
    resp = http_conn.getresponse()
  File "/usr/local/lib/python3.10/http/client.py", line 1374, in getresponse
    response.begin()
  File "/usr/local/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.10/http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.10/socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.10/ssl.py", line 1274, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.10/ssl.py", line 1130, in read
    return self._sslobj.read(len, buffer)
TimeoutError: The read operation timed out
travisghansen commented 1 year ago

Yeah the gathering of addresses via the arp table can be an time consuming process especially when it’s told to lookup hostnames for each device. Sometimes the hostname lookups cause throttling etc if you’re using funny dns features (ad-guard).

gotschi commented 1 year ago

its quite sporadic, I have no idea what makes it trigger. will close for now as its just a minor thing

doguitar commented 1 year ago

I'm getting this error when trying to enable device tracking (new installation).

It doesn't seem minor as I can't enable the feature as it stands.

gotschi commented 1 year ago

I'm getting this error when trying to enable device tracking (new installation).

It doesn't seem minor as I can't enable the feature as it stands.

Try again sometime later, it works for me at least that way. And as travis said, Adguard does some rate limiting, I've set mine to 0 (clients can inifinitely request)

JimmyMPage commented 10 months ago

I'm getting this error when trying to enable device tracking (new installation). It doesn't seem minor as I can't enable the feature as it stands.

Try again sometime later, it works for me at least that way. And as travis said, Adguard does some rate limiting, I've set mine to 0 (clients can inifinitely request)

I had this issue, thought I had it fixed, and then it came back and I went looking for a solution again. You nailed my issue...as I had just installed Adguard and couldn't figure out how it was breaking the integration. Thank you!