zhulik / aiotractive

Asynchronous Python client for the Tractive REST API
MIT License
21 stars 6 forks source link

Improve reliability (keep alive timeout issue) #19

Closed oandrew closed 1 year ago

oandrew commented 1 year ago

I was getting frequent Tractive is not available. Internet connection is down? Sleeping 10 seconds and retrying errors in my home assistant.

Turns out, Tractive api occasionally "restarts" the stream by sending a new "handshake" message. In such scenarios, the duration between keep-alive messages is ~10s which is higher than current 7s. Logs:

2023-08-21 23:30:08.103680
b'{"message":"keep-alive", ...}\n'

2023-08-21 23:30:11.142572
b'{"message":"tracker_status", ...}\n'

2023-08-21 23:30:13.833765
b'{"message":"handshake", ...}\n'

2023-08-21 23:30:14.025513
b'{"message":"tracker_status", ...}\n'

2023-08-21 23:30:14.177498
b'{"message":"activity_update", ...}\n'

2023-08-21 23:30:14.223398
b'{"message":"wellness_overview", ...}\n'

2023-08-21 23:30:16.379405 <<CURRENT LOGIC TIMES OUT HERE>>

2023-08-21 23:30:16.703810
b'{"message":"tracker_status", ...}\n'

2023-08-21 23:30:18.833432
b'{"message":"keep-alive", ...}\n'
zhulik commented 1 year ago

@oandrew version 0.5.6 with your fix has been released. Thanks again!