Closed joaoasilva closed 4 years ago
what version are you on? and also ssh or telnet?
ssh, but I remember having the same issue with telnet previously. Home assistant 0.84.6
Looking forward to that log! Thank you for the helping hand :)
2019-01-05 06:56:38 INFO (MainThread) [homeassistant.components.device_tracker.asuswrt] Checking Devices 2019-01-05 06:56:51 WARNING (MainThread) [homeassistant.components.device_tracker] Updating device list from asuswrt took longer than the scheduled scan interval 0:00:12
nothing useful I'm afraid...
There seems to be many bugreports on hass for this in general, is it not a general bug in hass rather than aioasuswrt?
I don't think so, if I restart my router it starts working again because that way it detects that it was disconnected and reconnects again.
I've added more debug lines around the whole code, I'll let you know if I find anything relevant
I've noticed now that restarting the router this errors start and never go back to normal:
2019-01-24 22:39:38 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.rt_ac86u_packets_received fails Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 902, in _wrap_create_connection await self._loop.create_connection(*args, **kwargs)) File "/usr/lib/python3.5/asyncio/base_events.py", line 775, in create_connection raise exceptions[0] File "/usr/lib/python3.5/asyncio/base_events.py", line 762, in create_connection yield from self.sock_connect(sock, address) File "/usr/lib/python3.5/asyncio/selector_events.py", line 451, in sock_connect return (yield from fut) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in iter yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/asyncio/selector_events.py", line 481, in _sock_connect_cb raise OSError(err, 'Connect call failed %s' % (address,)) ConnectionRefusedError: [Errno 111] Connect call failed ('xxx.xxx.xxx.xxx', 48547)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state await self.async_device_update() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update await self.async_update() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/upnp.py", line 163, in async_update self._state = await self._device.async_get_total_packets_received() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/upnp/device.py", line 150, in async_get_total_packets_received return await self._igd_device.async_get_total_packets_received() File "/srv/homeassistant/lib/python3.5/site-packages/async_upnp_client/igd.py", line 98, in async_get_total_packets_received result = await action.async_call() File "/srv/homeassistant/lib/python3.5/site-packages/async_upnp_client/init.py", line 622, in async_call await self.service.requester.async_http_request('POST', url, headers, body) File "/srv/homeassistant/lib/python3.5/site-packages/async_upnp_client/init.py", line 79, in async_http_request body_type=body_type) File "/srv/homeassistant/lib/python3.5/site-packages/async_upnp_client/aiohttp.py", line 80, in async_do_http_request async with self._session.request(method, url, headers=headers, data=body) as response: File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client.py", line 932, in aenter self._resp = await self._coro File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client.py", line 403, in _request timeout=real_timeout File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 500, in connect proto = await self._create_connection(req, traces, timeout) File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 832, in _create_connection req, traces, timeout) File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 970, in _create_direct_connection raise last_exc File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 952, in _create_direct_connection req=req, client_error=client_error) File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/connector.py", line 909, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host xxx.xxx.xxx.xxx:48547 ssl:None [Connect call failed ('xxx.xxx.xxx.xxx', 48547)]
That is for upnp! That is not the same component as asuswrt
I know but that's when this keeps appearing non-stop until I restart HA
(MainThread) [homeassistant.helpers.entity] Update for sensor.rt_ac86u_packets_received fails
It seems all connections to router go down from HA in that case, could you try to only use asuswrt for a while?
It keeps happening, doesn't matter what I try. There's also more people complaining here: https://github.com/home-assistant/home-assistant/issues/20851 so its definetely not an isolated issue.
Thanks.
Can anyone try pip install https://github.com/kennedyshead/aioasuswrt/archive/master.zip
If that makes any change.
Same issue also for me, stop working after some hours. Kennedy how to install that zip?
Same issue, starting happening out of the blue tbh. Was working fine. Some more logs if it helps. I'm using telnet on hass.io image for raspberry pi
Unable to read from router on 192.168.1.1:23
Error setting up platform asuswrt
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 173, in async_setup_platform
hass, {DOMAIN: p_config})
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 20, in async_get_scanner
await scanner.async_connect()
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 37, in async_connect
data = await self.connection.async_get_connected_devices()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 168, in async_get_connected_devices
dev = await self.async_get_arp()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 148, in async_get_arp
lines = await self.connection.async_run_command(_ARP_CMD)
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/connection.py", line 97, in async_run_command
data = ((await self._reader.readuntil(self._prompt_string)).
File "/usr/local/lib/python3.6/asyncio/streams.py", line 578, in readuntil
raise IncompleteReadError(chunk, None)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of None expected bytes
Then this:
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 708, in async_device_tracker_scan
found_devices = await scanner.async_scan_devices()
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 42, in async_scan_devices
await self.async_update_info()
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 58, in async_update_info
self.last_results = await self.connection.async_get_connected_devices()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 168, in async_get_connected_devices
dev = await self.async_get_arp()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 148, in async_get_arp
lines = await self.connection.async_run_command(_ARP_CMD)
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/connection.py", line 91, in async_run_command
await self.async_connect()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/connection.py", line 124, in async_connect
b'#')).split(b'\n')[-1]
File "/usr/local/lib/python3.6/asyncio/streams.py", line 578, in readuntil
raise IncompleteReadError(chunk, None)
asyncio.streams.IncompleteReadError: 89 bytes read on a total of None expected bytes
Then the logs are filled with Update of xxx is taking over 10 seconds
and the same issue took longer that 0:00:12
error the others are getting.
Can anyone try
pip install https://github.com/kennedyshead/aioasuswrt/archive/master.zip
If that makes any change.
I'm having the same issue - tried out this and it hasn't helped sorry. Similarly to others, the component was working after a recent update, and broke again at some point in the last week or so.
I have the same problem and drilled it down to too many open sessions on router. How to check:
netstat -t
and if you use telnet netsat -t | grep telnet| wc -l
If you have more than 20 you have problem, I have ~400 and then it stops working.I just opend a issue for that #25 and comment in "AsusWRT config issue #20123" at https://github.com/home-assistant/home-assistant
Aha! Well that is easy to fix please try: pip install https://github.com/kennedyshead/aioasuswrt/archive/master.zip
again
And @flysen @danieljmiles Thank you for the information, lets hope this solves the issue :)
@kennedyshead OMG! You are quick :-) Ill check your update tonight and get back.
I have this problem with SSH... not sure it it will fix it?
No it will not, Im stil not sure about why ssh is causing problems
@joaoasilva you could try @flysen netstat test!
@kennedyshead @joaoasilva Just information. Without knowing which dist Asus are based on... Best practice is to limit number of concurrent sessions for telnet/ssh before it brakes and run out of something (memory) etc. Frankly I haven't looked into that for Asus but my guess is they use "unlimited" which could lead to problem. I assume that enterprise product, not intend for consumers, have it sorted out in a better way than my Asus router. The only option I have in the router GUI is to close connection after a value between 10-99?!?
And of course don't forget to check the logs on the router...
@kennedyshead
Logged into the container and pip install --upgrade https://github.com/kennedyshead/aioasuswrt/archive/master.zip
root@peahass:/# pip install --upgrade https://github.com/kennedyshead/aioasuswrt/archive/master.zip
Collecting https://github.com/kennedyshead/aioasuswrt/archive/master.zip
Downloading https://github.com/kennedyshead/aioasuswrt/archive/master.zip
/ 163kB 705kB/s
Requirement already satisfied, skipping upgrade: asyncssh==1.15.0 in /usr/local/lib/python3.6/site-packages (from aioasuswrt==1.1.20) (1.15.0)
Requirement already satisfied, skipping upgrade: cryptography>=1.5 in /usr/local/lib/python3.6/site-packages (from asyncssh==1.15.0->aioasuswrt==1.1.20) (2.3.1)
Requirement already satisfied, skipping upgrade: cffi!=1.11.3,>=1.7 in /usr/local/lib/python3.6/site-packages (from cryptography>=1.5->asyncssh==1.15.0->aioasuswrt==1.1.20) (1.11.5)
Requirement already satisfied, skipping upgrade: six>=1.4.1 in /usr/local/lib/python3.6/site-packages (from cryptography>=1.5->asyncssh==1.15.0->aioasuswrt==1.1.20) (1.12.0)
Requirement already satisfied, skipping upgrade: asn1crypto>=0.21.0 in /usr/local/lib/python3.6/site-packages (from cryptography>=1.5->asyncssh==1.15.0->aioasuswrt==1.1.20) (0.24.0)
Requirement already satisfied, skipping upgrade: idna>=2.1 in /usr/local/lib/python3.6/site-packages (from cryptography>=1.5->asyncssh==1.15.0->aioasuswrt==1.1.20) (2.8)
Requirement already satisfied, skipping upgrade: pycparser in /usr/local/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography>=1.5->asyncssh==1.15.0->aioasuswrt==1.1.20) (2.19)
Building wheels for collected packages: aioasuswrt
Building wheel for aioasuswrt (setup.py) ... done
Stored in directory: /tmp/pip-ephem-wheel-cache-wku9idz4/wheels/88/0a/48/a1b6093a04ce78ebb0d0afd1ff81b14443ee71e1b1be90ad80
Successfully built aioasuswrt
Installing collected packages: aioasuswrt
Found existing installation: aioasuswrt 1.1.20
Uninstalling aioasuswrt-1.1.20:
Successfully uninstalled aioasuswrt-1.1.20
Successfully installed aioasuswrt-1.1.20
Now after ~1h:
admin@RT-N66U:/tmp# netstat -t| grep telnet| wc -l
give me just 2 connections (and one of them is my terminal). Hope for the best, Ill check again tomorrow to confirm.
Thanks
@kennedyshead same good results after 12h, works like a charm :-)
I'm starting to think that the ssh version have the same problem, if someone with this problem over ssh could test with netstat it would be appreciated.
I'm starting to think that the ssh version have the same problem, if someone with this problem over ssh could test with netstat it would be appreciated.
@kennedyshead couldn't you just add logging when connection in opend and then closed with pid included in logline. Just for debugging?
And by the way, my router are really happy now, without need to handle all telnet sessions :-)
I will try again but at the moment I might have broken my env after trying pip install --upgrade https://github.com/kennedyshead/aioasuswrt/archive/master.zip I'm getting:
2019-02-19 09:43:30 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform asuswrt
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 173, in async_setup_platform
hass, {DOMAIN: p_config})
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 20, in async_get_scanner
await scanner.async_connect()
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 37, in async_connect
data = await self.connection.async_get_connected_devices()
File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 166, in async_get_connected_devices
dev = await self.async_get_wl()
File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 102, in async_get_wl
lines = await self.connection.async_run_command(_WL_CMD)
File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/connection.py", line 37, in async_run_command
"%s && %s" % (_PATH_EXPORT_COMMAND, command)), 9)
File "/usr/lib/python3.5/asyncio/tasks.py", line 387, in wait_for
fut = ensure_future(fut, loop=loop)
File "/usr/lib/python3.5/asyncio/tasks.py", line 567, in ensure_future
raise TypeError('A Future, a coroutine or an awaitable is required')
TypeError: A Future, a coroutine or an awaitable is required
@joaoasilva No I don't think so, it looks like the problem is that HASS try to do stuff to early. I have the same log error. But then it'll establish a connection and continue with life. Think that's a separate issue.
2019-02-19 00:04:08 ERROR (MainThread) [aioasuswrt.connection] Unable to read from router on 172.16.1.1:23
2019-02-19 00:04:08 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform asuswrt Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 173, in async_setup_platform hass, {DOMAIN: p_config})
File "/usr/src/app/homeassistant/components/device_tracker/asuswrt.py", line 20, in async_get_scanner await scanner.async_connect()
File "/usr/src/app/homeassistant/components/device_tracker/asuswrt.py", line 37, in async_connect data = await self.connection.async_get_connected_devices()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 166, in async_get_connected_devices dev = await self.async_get_wl()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 102, in async_get_wl lines = await self.connection.async_run_command(_WL_CMD)
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/connection.py", line 102, in async_run_command self._prompt_string), 9)).split(b'\n')[1:-1])
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for return fut.result()
File "/usr/local/lib/python3.6/asyncio/streams.py", line 578, in readuntil raise IncompleteReadError(chunk, None) asyncio.streams.IncompleteReadError: 0 bytes read on a total of None expected bytes
2019-02-19 00:04:09 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 708, in async_device_tracker_scan found_devices = await scanner.async_scan_devices()
File "/usr/src/app/homeassistant/components/device_tracker/asuswrt.py", line 42, in async_scan_devices await self.async_update_info()
File "/usr/src/app/homeassistant/components/device_tracker/asuswrt.py", line 58, in async_update_info self.last_results = await self.connection.async_get_connected_devices()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 166, in async_get_connected_devices dev = await self.async_get_wl()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/asuswrt.py", line 102, in async_get_wl lines = await self.connection.async_run_command(_WL_CMD)
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/connection.py", line 95, in async_run_command await self.async_connect()
File "/usr/local/lib/python3.6/site-packages/aioasuswrt/connection.py", line 139, in async_connect b'#')).split(b'\n')[-1] File "/usr/local/lib/python3.6/asyncio/streams.py", line 578, in readuntil raise IncompleteReadError(chunk, None) asyncio.streams.IncompleteReadError: 90 bytes read on a total of None expected bytes
Mine doesn't work at all with that error, don't know what to do anymore :(
I'm on it ;) Limited sparetime atm.
Meantime try: pip install aioasuswrt --upgrade
If I revert to before this commit, it doesn't give me that error https://github.com/kennedyshead/aioasuswrt/commit/0acf75cbda5464b4f429b1133caa3df41e18386b
I know :) I'll have a fix for that asap.
So, on my router I have 1 ssh connection from aioasuswrt at the moment. My syslog.log on the router doesn't have any login attempts from aioasuswrt but it's giving
Updating device list from asuswrt took longer than the scheduled scan interval 0:00:12
all the time. When I restart aioasuswrt I get a successful login attempt on the router and it starts working again.
@joaoasilva try pip install https://github.com/kennedyshead/aioasuswrt/archive/master.zip again
If I install the latest I get the
TypeError: A Future, a coroutine or an awaitable is required
File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/connection.py", line 37
That should be sorted now
I'm having the same issue still, even after updating to the master branch. Router: Asus RT-N66U, using telnet
Router shows a lot of: "Feb 23 18:12:15 login[3350]: root login on 'pts/53'" with the /53 ever increasing (about once a second or so) Then after a while I get the "Feb 23 18:09:20 telnetd[298]: vfork: Cannot allocate memory" messages in the router's log.
HA log shows:
2019-02-23 18:15:48 ERROR (MainThread) [aioasuswrt.connection] Unable to read from router on 192.168.1.1:23 2019-02-23 18:15:48 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform asuswrt Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 173, in async_setup_platform hass, {DOMAIN: p_config}) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 20, in async_get_scanner await scanner.async_connect() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 37, in async_connect data = await self.connection.async_get_connected_devices() File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 166, in async_get_connected_devices dev = await self.async_get_wl() File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 102, in async_get_wl lines = await self.connection.async_run_command(_WL_CMD) File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/connection.py", line 97, in async_run_command data = ((await self._reader.readuntil(self._prompt_string)). File "/usr/lib/python3.5/asyncio/streams.py", line 572, in readuntil raise IncompleteReadError(chunk, None) asyncio.streams.IncompleteReadError: 0 bytes read on a total of None expected bytes 2019-02-23 18:15:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step result = coro.send(None) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 708, in async_device_tracker_scan found_devices = await scanner.async_scan_devices() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 42, in async_scan_devices await self.async_update_info() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 58, in async_update_info self.last_results = await self.connection.async_get_connected_devices() File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 166, in async_get_connected_devices dev = await self.async_get_wl() File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 102, in async_get_wl lines = await self.connection.async_run_command(_WL_CMD) File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/connection.py", line 91, in async_run_command await self.async_connect() File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/connection.py", line 124, in async_connect b'#')).split(b'\n')[-1] File "/usr/lib/python3.5/asyncio/streams.py", line 572, in readuntil raise IncompleteReadError(chunk, None) asyncio.streams.IncompleteReadError: 86 bytes read on a total of None expected bytes
That should be sorted now
Seems that the issue have stopped! Went all weekend without having to restart, amazing! Thanks @kennedyshead The only thing that now I get from time to time is this:
2019-02-23 21:32:48 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step result = coro.send(None) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/init.py", line 708, in async_device_tracker_scan found_devices = await scanner.async_scan_devices() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 42, in async_scan_devices await self.async_update_info() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py", line 58, in async_update_info self.last_results = await self.connection.async_get_connected_devices() File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 166, in async_get_connected_devices dev = await self.async_get_wl() File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 105, in async_get_wl result = await _parse_lines(lines, _WL_REGEX) File "/srv/homeassistant/lib/python3.5/site-packages/aioasuswrt/asuswrt.py", line 67, in _parse_lines for line in lines: TypeError: 'coroutine' object is not iterable
I'm having the same issue still, even after updating to the master branch.
Did a pip uninstall and new pip install and now it is indeed solved. Sorry for my earlier report!
Is this going to be in the next home assistant update?
Updating device list from asuswrt took longer than the scheduled scan interval 0:00:12 Need to restart Home Assistant for it to start working again.
I've enabled logs now and I'll let you know the outcome. On the previous version (old non-async code on Home Assistant) I had to disconnect and reconnect the session when this happened, guess it still happens the same and the plugin doesn't figure out it lost the connection to the router