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

Close ws connections inactive for more than x seconds #846

Open
pieroit opened this issue Jun 1, 2024 · 13 comments
Open

Close ws connections inactive for more than x seconds #846

pieroit opened this issue Jun 1, 2024 · 13 comments
Assignees
Labels
endpoints Related to http / ws endpoints enhancement New feature or request

Comments

@pieroit
Copy link
Member

pieroit commented Jun 1, 2024

At the moment all ws connections remain open forever XD
We can check the old ones and close them, maybe using the WhiteRabbit by @jacopopalumbo01 or (tmp) just running a loop on active connections when a new user tries to connect, and close the old inactive ones

@pieroit pieroit added the enhancement New feature or request label Jun 1, 2024
@pieroit pieroit moved this to 🔖 Ready in Cat Project Kanban Jun 1, 2024
@pieroit pieroit added the endpoints Related to http / ws endpoints label Jun 1, 2024
@Pingdred Pingdred self-assigned this Jun 2, 2024
@pieroit
Copy link
Member Author

pieroit commented Jun 17, 2024

Can be done with the WhiteRabbit

@jacopopalumbo01
Copy link
Contributor

I'm here

@zAlweNy26
Copy link
Member

I don't think the WhiteRabbit is needed.
Check this out: https://stackoverflow.com/questions/63847205/fastapi-websocket-ping-pong-timeout
and https://websockets.readthedocs.io/en/stable/topics/timeouts.html#keepalive-in-websockets (the library used under the hood)

@pieroit
Copy link
Member Author

pieroit commented Aug 7, 2024

I don't think the WhiteRabbit is needed. Check this out: https://stackoverflow.com/questions/63847205/fastapi-websocket-ping-pong-timeout and https://websockets.readthedocs.io/en/stable/topics/timeouts.html#keepalive-in-websockets (the library used under the hood)

Awesome!
So I guess we just need to delete the stray once ws disconnects

# del strays[user_id]

@pieroit
Copy link
Member Author

pieroit commented Aug 7, 2024

Or there was a reason for not deleting it?
Can you remember @Pingdred ?

@Pingdred
Copy link
Member

Pingdred commented Aug 8, 2024

Or there was a reason for not deleting it?
Can you remember @Pingdred ?

We chose not to delete it just to preserve Working Memory in case of disconnection

@jacopopalumbo01
Copy link
Contributor

And deleting the stray instance may arise problems when an action using the stray is scheduled in the WhiteRabbit.

@pieroit
Copy link
Member Author

pieroit commented Sep 20, 2024

Proposal:
As soon as the stray is created, white rabbit will check every x minutes if it is active or not
If not, it gets deleted

Unless as @jacopopalumbo01 said there is a breaking dependency between the objects

@pieroit
Copy link
Member Author

pieroit commented Sep 23, 2024

After 23/09/2024 dev meeting:

Have a new SessionManager that is used here to store, get, create and delete expired StrayCat objects

@matteocacciola

This comment was marked as abuse.

@pieroit
Copy link
Member Author

pieroit commented Oct 7, 2024

Hello all, just a quick question: why not handling the ConnectionClosed exception and destroy the instance of StrayCat therein (https://websockets.readthedocs.io/en/stable/topics/keepalive.html#keepalive-in-websockets)?

Because you may lose the websocket connection but still want to reattach the same conversation

@scicco scicco mentioned this issue Oct 15, 2024
4 tasks
@scicco
Copy link

scicco commented Oct 15, 2024

Hello,

I've added a feature to manage the session expiration, as @valentimarco and I suggested during a previous dev meeting.

Hope this could help

@pieroit
Copy link
Member Author

pieroit commented Oct 21, 2024

PR in review, merging soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
endpoints Related to http / ws endpoints enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

6 participants