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

Is there a way to close the subscription from the server? #1427

Closed
yaziciahmet opened this issue Jul 20, 2024 · 5 comments
Closed

Is there a way to close the subscription from the server? #1427

yaziciahmet opened this issue Jul 20, 2024 · 5 comments

Comments

@yaziciahmet
Copy link

My confusion is really simple. I have a usecase where it is best to close the subscription or the connection from the server-side. Is this achievable, if so how?

@niklasad1
Copy link
Member

Hey @yaziciahmet

I don't understand whether you want to close the just subscription or the entire connection.

  1. Closing the subscription is trivial just return early from your subscription callback but you may want to send a special message before do so because the client will never know. See Are clients notified when a subscription task exists? #1223 for further information.
  2. Closing the connection is possible but quite complicated to implement where you have to use the low-level server API via middleware/extensions accessible in subscription callback to indicate to close down the connection.

@yaziciahmet
Copy link
Author

Hey @niklasad1

I believe what I want is the ability to close the connection. It looks quite complicated to do. Is it planned anytime soon to add some sort of easier access to underlying connection, or maybe just a close functionality can be propagated down somehwo?

@niklasad1
Copy link
Member

I prefer not add such thing into the subscription itself but perhaps we could add some builtin middleware to simplify it.
I have to double-check myself whether it's possible to implement...

@yaziciahmet
Copy link
Author

Maybe return a tuple from pending.accept()? Subscription itself and a close callback?

@niklasad1
Copy link
Member

niklasad1 commented Nov 1, 2024

Hey sorry, for late response but I had a look at this and it's currently possible to add such as thing using extensions in the RPC handler by using the low-level server API example here

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

No branches or pull requests

3 participants
@niklasad1 @yaziciahmet and others