Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'SshConnection' object has no attribute '_client' #27783

Closed
tiagofreire-pt opened this issue Oct 17, 2019 · 38 comments · Fixed by kennedyshead/aioasuswrt#37 or #34454
Closed

Comments

@tiagofreire-pt
Copy link
Contributor

Home Assistant release with the issue:
0.100.2

Last working Home Assistant release (if known):
N/K

Operating environment (Hass.io/Docker/Windows/etc.):
Hassio

Integration:
AsusWRT

Description of problem:
Integration crashes and cause problems with device tracking.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

asuswrt: 
  host: !secret asuswrt_host
  username: !secret asuswrt_username
  ssh_key: '/config/custom_components/asuswrt_ssh/asuswrt_ssh_key'
#  password: !secret asuswrt_password
  sensors: 
    - upload 
    - download 
    - upload_speed
    - download_speed

Traceback (if applicable):

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 164, in async_device_tracker_scan
    found_devices = await scanner.async_scan_devices()
  File "/usr/src/homeassistant/homeassistant/components/asuswrt/device_tracker.py", line 36, in async_scan_devices
    await self.async_update_info()
  File "/usr/src/homeassistant/homeassistant/components/asuswrt/device_tracker.py", line 52, in async_update_info
    self.last_results = await self.connection.async_get_connected_devices()
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/asuswrt.py", line 168, in async_get_connected_devices
    dev = await self.async_get_arp()
  File "/usr/local/lib/python3.7/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.7/site-packages/aioasuswrt/connection.py", line 37, in async_run_command
    result = await asyncio.wait_for(self._client.run(
AttributeError: 'SshConnection' object has no attribute '_client'

Additional information:

@probot-home-assistant
Copy link

Hey there @kennedyshead, mind taking a look at this issue as its been labeled with a integration (asuswrt) you are listed as a codeowner for? Thanks!

@Tekno-man
Copy link

Tekno-man commented Oct 19, 2019

Hi All, I started having the same error last night for presence and sensors.

Update for sensor.asuswrt_upload_speed fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 268, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 446, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/asuswrt/sensor.py", line 91, in async_update
    await super().async_update()
  File "/usr/src/homeassistant/homeassistant/components/asuswrt/sensor.py", line 56, in async_update
    self._rates = await self._api.async_get_bytes_total()
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/asuswrt.py", line 189, in async_get_bytes_total
    rx = await self.async_get_rx()
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/asuswrt.py", line 195, in async_get_rx
    data = await self.connection.async_run_command(_RX_COMMAND)
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/connection.py", line 37, in async_run_command
    result = await asyncio.wait_for(self._client.run(
AttributeError: 'SshConnection' object has no attribute '_client'

Here is my config, I am not using SSH key.

asuswrt:
  host: 192.168.1.1
  username: !secret asus_user
  password: !secret asus_password
  sensors:
   - upload
   - download
   - upload_speed
   - download_speed
   
device_tracker:
  - platform: asuswrt
    host: 192.168.1.1
    username: !secret asus_user
    password: !secret asus_password 
    interval_seconds: 12
    consider_home: 30
    new_device_defaults:
      track_new_devices: true
      hide_if_away: false

Running 0.100.2 but I updated a few days ago and only just now started having problem.

Cheers

@Tekno-man
Copy link

Tekno-man commented Oct 20, 2019

Tried rolling back to 0.99.3 and still has same problem. I have also tried SSH into router with same credentials and am able to get access. I also tried removing the setup from the Config file restarting, adding config back in. This helped as the status has been updating sometimes but therefore the status is not accurate and presence detection keeps flicking between away and home every 7 minutes or so and then eventually stops responding.

@kennedyshead
Copy link
Contributor

I just noticed this myself, working on a fix.

@Tekno-man
Copy link

I'm surprised no one else has commented saying they have the same problem. I thought this was a popular implementation, have others not suffered the same problem? is there some other work around?

@Tekno-man
Copy link

I have tried using SSH key and this produces the same error. I have also tried using telnet and this doesn't have the same error but the error is a connection time out but I am able to telnet into the router using the same settings.

Host timeout.
5:24 PM components/asuswrt/sensor.py (ERROR)

@tiagofreire-pt
Copy link
Contributor Author

@Tekno-man , do you use the Merlin version 384.13_1?

@Tekno-man
Copy link

@ticapix I have stock firmware Current Version : 3.0.0.4.384_45149-g467037b. Not sure what Merlin is.

@thundergreen
Copy link

thundergreen commented Nov 8, 2019

SshConnection' object has no attribute '_client' BINGO!! Have the same issue .. latest 101.3 Hassio intel nuc ubuntu docker install I got this error after adding the sensor !

  sensors:
   - upload
   - download
   - upload_speed
   - download_speed

This might be related to the sensor in asuwrt component

On top of this i get device_tracker issues. Suddenly the device tracker stops working ... my system turns on my alarmsystem.. lights off and stuff :P .. not really funny. if someone opens a door or window .. bingo!!! alarm siren fired nicely .. I have the feeling the device tracker has a bug since 101.x

@thundergreen
Copy link

@tiagofreire-pt I use 384.13_0 on asus RTac68U

@AirmakZ
Copy link

AirmakZ commented Nov 26, 2019

@kennedyshead, do you have news about the route cause of this issue?
I'm having same problem from some versions ago (not sure which one). It works after HA restart during few days, but suddenly it fails with exactly same error as mentioned in this topic. I could not identify a trigger...
I'm not using ssh.
Thanks !

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Dec 3, 2019

after having disabled the Asus: integration for a long time, today thought it might be a good time to re-enable on 102.2/3.

no such luck, this error is still there unfortunately. Is anyone aware of any dev / code-owner taking this at heart?

@roblandry
Copy link
Contributor

I am having the same issue for several days/weeks... I also just moved to using aimesh yesterday. I will see if I am able to assist with tracking down the issue. Fingers crossed!

@roblandry
Copy link
Contributor

roblandry commented Dec 7, 2019

So at first glance, there is no issue with the router or the code. It is failing to connect on my production server, yet it is working on my development server. I am wondering if something else in the background is causing the problem... like another component, a python module of a different version, etc.

UPDATE: I've added some debug logs, we will see if it sheds any light on the problem. Currently it is now working again on my production server.

@calexandre
Copy link

calexandre commented Feb 8, 2020

Any news on this one? I'm on 0.104.3 and the issue is still present :/

@fedebruni84
Copy link

Same problem here in 0.105.3!
It's strange because in 0.104.3 the issue appeared very rarely.
In 0.105.3 it is present several thousand times per day (log file is 70 MB after 1 day ;) )

@ngseer
Copy link

ngseer commented Feb 13, 2020

I can confirm there are literally thousands of log entries with 0.105.3.
And that's what appears at my router's syslog right before each series of these errors in the HA log:

Feb 13 01:00:17 dropbear[12018]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:41372
Feb 13 01:00:28 dropbear[12025]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:41476
Feb 13 01:00:38 dropbear[12033]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:41576
Feb 13 01:00:57 dropbear[12082]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:42552
Feb 13 01:01:12 dropbear[12092]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:43384
Feb 13 01:01:13 dropbear[12091]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:43380
Feb 13 01:01:15 dropbear[12093]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:43386
Feb 13 01:01:15 dropbear[12094]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:43388
Feb 13 01:02:56 dropbear[12304]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:46938
Feb 13 01:03:35 dropbear[12369]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:48252
Feb 13 01:04:10 dropbear[12434]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:49204
Feb 13 01:05:03 dropbear[12571]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:51512
Feb 13 01:05:19 dropbear[12582]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:52126
Feb 13 01:05:20 dropbear[12580]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:52124
Feb 13 01:05:22 dropbear[12579]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:52122
Feb 13 01:05:22 dropbear[12586]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:52136
Feb 13 01:05:23 dropbear[12583]: Pubkey auth succeeded for '█████' with key sha1!! [DATA EXPUNGED] from 192.168.1.███:52128

Then I can see a lot of dropbear spawns with established connections on port 22 at router side while HA side still has only one open connection as if all these connections were not properly closed.
In the worst case I had dozens of these spawns and router's CPU was utilized at 100% with 90+% at sirq. Turned off the integration, rebooted the router — problem's gone.

Also not sure if this is related but if I restart HA these errors usually start occurring again near 00:00 or 01:00.

@kennedyshead
Copy link
Contributor

I have not seen this since 100.x in my system... thought I fixed it. Sorry :/ There might be a problem if there is a temporary "glitch" in connection

@myshyak
Copy link

myshyak commented Feb 14, 2020

Same issue. 0.105.3

@jdelahayes
Copy link

same issue 0.107.7

@odelli
Copy link

odelli commented Apr 3, 2020

Same issue. 0.107.7

Edit: Also with 0.108.5.

@Valen13776
Copy link

Also with 0.108.5.

@achilleus68
Copy link

Also with 0.108.4

@kennedyshead
Copy link
Contributor

Stupid of me, I just found the bug! I'll prepare a new release of aioasuswrt

@odelli
Copy link

odelli commented Apr 29, 2020

Still in 0.108.9

@freakshock88
Copy link

Still in 0.108.9

It should be in 0.109.
Let's hope this fixes the issue for once and for all :)

@odelli
Copy link

odelli commented Apr 29, 2020

Sorry, I thought the fix was in an earlier release. Thanks!

@achilleus68
Copy link

achilleus68 commented May 1, 2020

Still getting errors in 0.109

Logger: homeassistant.core
Source: components/asuswrt/device_tracker.py:52
First occurred: 30 april 2020 22:42:33 (1617 occurrences)
Last logged: 8:32:50

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 161, in async_device_tracker_scan
    found_devices = await scanner.async_scan_devices()
  File "/usr/src/homeassistant/homeassistant/components/asuswrt/device_tracker.py", line 36, in async_scan_devices
    await self.async_update_info()
  File "/usr/src/homeassistant/homeassistant/components/asuswrt/device_tracker.py", line 52, in async_update_info
    self.last_results = await self.connection.async_get_connected_devices()
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/asuswrt.py", line 312, in async_get_connected_devices
    dev = await self.async_get_arp()
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/asuswrt.py", line 287, in async_get_arp
    lines = await self.connection.async_run_command(_ARP_CMD)
  File "/usr/local/lib/python3.7/site-packages/aioasuswrt/connection.py", line 39, in async_run_command
    result = await asyncio.wait_for(self._client.run(
AttributeError: 'NoneType' object has no attribute 'run'

@tkdrob
Copy link
Contributor

tkdrob commented May 13, 2020

Same here. 0.109.6

@yg070520
Copy link

I am pretty sure in earlier version maybe 0.8x ,no such issue.

@achilleus68
Copy link

achilleus68 commented Sep 2, 2020

Will this ever be fixed? Still not working in Home Assistant 0.114.4

@Mknutas
Copy link

Mknutas commented Sep 2, 2020

Stop digging up old unrelated issues, the last stacktrace is a completely new one and would have got sorted if there was a new issue with all info provided.

@achilleus68
Copy link

Wow.
I am not "digging up old issues", I'm responding to ONE thread I already was part of.
My HA installation will still not update statuses of devices, so for me it is still not working

And yes this issue is closed, but for me not resolved.
No need to react like that.

@kennedyshead
Copy link
Contributor

kennedyshead commented Sep 2, 2020

Im not doing more than to say that the reason for missing this is that its unrelated to this issue. I'm not flaming and am not irritated or anything like <3
/Mknutas

@tkdrob
Copy link
Contributor

tkdrob commented Sep 2, 2020

@djiest which asus router do you have? I'm running ac5300 with 384.18, soon to be 384.19. Try other firmware versions if you haven't tried already. It could also be an issue specific to your router model.

That's all I have to offer

@kennedyshead
Copy link
Contributor

kennedyshead commented Sep 2, 2020

@djiest I'm 100% sure that your hass can't access the router. Why that is I have no clue.

Firewall? Wrong ip (silly thing but could be). Du you have ssh turned on?

@achilleus68
Copy link

I'm using my router (previous AC66U, now RT-AX92U) for presence detection. That worked perfectly up to HA 0.108, after that I never got it working again. That's why I state that my issue isn't fixed. I've seen some threads about multirouter systems on the HA Forum so I will dive into that.
The actual error is "Error [[Errno 111] Connect call failed ('192.168.x.x', 22)] connecting asuswrt to 192.168.x.x. Will retry in 60 seconds...

As far as I'm concerned, new insights will I be posting in new issues.

@kennedyshead
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet