nordicopen / pyeasee

Easee EV charger API python library
MIT License
39 stars 11 forks source link

Add automatic reconnect to signalr #88

Closed jorgror closed 10 months ago

jorgror commented 10 months ago

Configure signalr core to use automatic reconnect with keep alive (ping) Ref: https://github.com/mandrewcito/signalrcore/tree/main#configuring-pingkeep-alive

keep_alive_interval is set to 15 seconds, which is equal to what easee.cloud uses.

This will send a ping every 15 seconds, and hopefully will improve reliability of the signalr connection.

olalid commented 10 months ago

Easee has specifically asked us to not do this. If their servers go offline, and all clients start to try and reconnect with 5 second intervals it is a big challenge for them to get them online again. We have implemented reconnect in the HA component instead which has increasing timeouts, so it will not put that load on the servers during startup.

jorgror commented 10 months ago

Would it be okey if we have reconnect as a parameter that default to false? That way home assistant can choose to use it without reconnect, while other consumers of the library can enable reconnect?

olalid commented 10 months ago

I remembered incorrectly, the reconnect logic is implemented in the lib, so it should already work. At least I have not noted any problems with reliability in the HA component. What is that you are seeing that you want to solve?

jorgror commented 10 months ago

I have noticed in some situations that the stream has been stuck and not recovering by itself. I have tried to recreated it, but I have not been sucessful. I will close this PR until I'm able to create a reproducable test and fix.

olalid commented 10 months ago

Ok, let us know if you find more details.

If it is possible to have the ping enabled without having the automatic reconnect, perhaps that would be ok. But I am not sure the lib supports that...?