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

listener Socket closes die to inactivity #27

Closed
alexkno79 opened this issue Aug 28, 2023 · 10 comments · Fixed by #64
Closed

listener Socket closes die to inactivity #27

alexkno79 opened this issue Aug 28, 2023 · 10 comments · Fixed by #64

Comments

@alexkno79
Copy link

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
Copy link
Owner

Leggin commented Aug 29, 2023

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

@alexkno79
Copy link
Author

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
Copy link
Contributor

fpb commented Oct 25, 2023

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
Copy link
Owner

Leggin commented Oct 26, 2023

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
Copy link
Author

alexkno79 commented Oct 26, 2023 via email

@Leggin Leggin closed this as completed Oct 28, 2023
@alexkno79
Copy link
Author

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 Leggin reopened this Apr 5, 2024
@Leggin Leggin linked a pull request Apr 5, 2024 that will close this issue
@Leggin Leggin closed this as completed in #64 Apr 5, 2024
@Leggin
Copy link
Owner

Leggin commented Apr 5, 2024

@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
Copy link
Author

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

@alexkno79
Copy link
Author

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 :)

@vaylvn
Copy link

vaylvn commented Sep 17, 2024

Apologies for the necro post,

I've been tinkering the past few days trying to find why exactly my script was locking up and I've managed to narrow it down to this module.

My theory is that the issue does indeed still persist where the event listener does eventually die out once no actions have occured for some time.

Is there a general concensus on how we should go about keeping it alive?

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

Successfully merging a pull request may close this issue.

4 participants