hass-aarlo
hass-aarlo copied to clipboard
Auto reconnect not working properly in v0.7.2b6.1
It looks like auto reconnect was not actually implemented before v0.7.2b6.1.
When it is implemented in v0.7.2b6.1, the behavior seems to be incorrect. After the reconnect_every period elapses, it calls backend.logout. If I read the code correctly, calling logout would actually stops the event loop and everything. The symptoms were nothing is working (no events coming in, and no actions, such as turning on/off lights, are effective). On top of this, the following error outputs once every minute, if v2 api is used:
failed to read modes (v2)
It seems to me that the reconnect daemon should not call logout directly. Instead, it should do everything logout except _event_stop_loop(), which stops the loop in _event_main, and thus stops relogging in.
In addition, it seems to me that SSEClient.disconnect() does not actually stop the iterator. In SSEClient.__next__, it does not check if self.running is still True or not, unless there is a problem with the decoding of an event. In reality, it may not be a problem since logout would call the logout API and invalidates the session (and thus terminates the SSE stream or causing an exception when decoding an event).
I am getting the same behavior, after reaching the reconnect timeout AArlo just logs out and all entities are unavailable in home assistant. Relevant event:
Logger: pyaarlo
Source: custom_components/aarlo/pyaarlo/__init__.py:668
Integration: Arlo Camera Support (documentation, issues)
First occurred: 01:16:23 (225 occurrences)
Last logged: 09:50:22
session start failed
authentication failed
failed to read modes (v2)
job-error=TypeError TypeError: 'NoneType' object is not iterable
2021-12-25 01:50:22 ERROR (ArloBackgroundWorker) [pyaarlo] failed to read modes (v2)
2021-12-25 01:50:22 ERROR (ArloBackgroundWorker) [pyaarlo] job-error=TypeError
My config:
aarlo:
username: !secret arlo_username
password: !secret arlo_password
stream_timeout: 120
request_timeout: 15
#recent_time: 10
#mode_api: v2
user_agent: android
#refresh_devices_every: 2
#refresh_modes_every: 5
reconnect_every: 30
http_connections: 5
http_max_size: 10
#host: https://my.arlo.com
#save_session: False
tfa_host: !secret arlo_tfa_host
tfa_username: !secret arlo_tfa_username
tfa_password: !secret arlo_tfa_password
It was working before update to 0.7.2b6.1
Following the thread, same behavior here.
Ok, I have completely removed the setting "reconnect_every: 30" from my config and after 12 hours connection seems to be stable. Maybe we don't need it anymore.
Same behavior Here. I also removed the "reconnect_every". Its now working for about 8 hours.
Me too. Removed this config yesterday and it's been more than 24 hours rock solid.
Same behaviour here. I have installed v0.7.2b6
Apologies, I added sse support back and turned on the reconnect_every for mqtt backends by mistake. I'll push a fix later.
As you discovered, if you're using mqtt just remove the reconnect_very option.
@twrecked for the record, I am using SSE backend, and reconnect_every does not work properly either.
I properly broke it then. I'll take a look later.
0.7.1 should work correctly with sse/reconnect_every for now.
It should be fixed in 0.7.2b7. For mqtt the reconnect_every parameter is ignored, for sse it now does the right thing.
@visualage I actually found 2 things wrong with the sse code, it should be good now, but let me know if anything looks wrong.