Leggin / dirigera

This repository provides an unofficial Python client for controlling the IKEA Dirigera Smart Home Hub.
MIT License
99 stars 19 forks source link

listener Socket closes die to inactivity #27

Closed alexkno79 closed 3 months ago

alexkno79 commented 10 months ago

After a while the listener stops after grateful closure of connection with closure code 1000 due to inactivity.

Could it be, the websocket needs some ping/pong to keep connection alive?

Leggin commented 10 months ago

Are you referring to an approach similar to this? https://websockets.readthedocs.io/en/stable/topics/timeouts.html#keepalive-in-websockets

alexkno79 commented 10 months ago

Yes, that's what I refer to. But indeed I do not know whether dirigera hub actually supports or needs it. I just see my event listener being closed after a while when no traffic is exchanged with closure code 1000

fpb commented 8 months ago

I don't experience that problem but that is probably because I have an air quality sensor that reports changes very frequently (several in a minute).

Leggin commented 8 months ago

I suggest then publishing a ping message every once in a while. I will try to verify if this works. Never experienced this also due to having the air quality sensor.

alexkno79 commented 8 months ago

Well in fact, since last weeks I don't see the connection drop anymore. Maybe with the new software IKEA dropped or enlarged the timeout. For the moment, I guess it could be considered as non issue

Nicolas Hilberg @.***> schrieb am Do., 26. Okt. 2023, 20:04:

I suggest then publishing a ping message every once in a while. I will try to verify if this works. Never experienced this also due to having the air quality sensor.

— Reply to this email directly, view it on GitHub https://github.com/Leggin/dirigera/issues/27#issuecomment-1781589226, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6ATSSTNEZTD45A3G4ON3VLYBKQZHAVCNFSM6AAAAAA4BXDKQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBRGU4DSMRSGY . You are receiving this because you authored the thread.Message ID: @.***>

alexkno79 commented 3 months ago

The behaviour reoccured and I see disconnection due to inactivity of the listener each 50 to 80 minutes when no updates occur. So maybe the ping would still be a good option. At the moment I workaround this by reconnecting on on-disconnect

Leggin commented 3 months ago

@alexkno79 I found that web socket has a ping interval parameter. I set it default to 60 seconds now, but it's exposed so it can be changed. If you find out a better default let me know.

alexkno79 commented 3 months ago

Thanks! I updated and keep an eye in it. Usually it happens overnight when no device is acting. I'll report back

alexkno79 commented 3 months ago

I see the pings and the pongs but still disconnections. So pinging seem not to keep the channel open. On the other hand, i have a third party zigbee outlet which sends a signal each 5 minutes, this keeps the connection stable :)