-
Notifications
You must be signed in to change notification settings - Fork 173
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
How to get notified on unsubscribe / drop connection #990
Comments
There is only jsonrpsee/core/src/server/rpc_module.rs Line 1044 in dab1bfc
I guess we could have an Thus, it's on it's way but I you use |
An alternative to that, depending on your use-case, would be to interact with the subscription. Let's presume the client has disconnected or called the unsubscribed method. jsonrpsee/core/src/server/rpc_module.rs Lines 893 to 900 in dab1bfc
To that regard, there is also this suggestion in discussion: #944, which would make things a bit more explicit to the user. Currently, you can shoot yourself in the foot with a code of those lines: loop {
match s.send() {
Ok(_) => // if it is false, then we should stop.
..
}} |
My use case is a JSON RPC proxy that forwards subscriptions to upstream server. So I will want to unsubscribe from upstream as soon as the downstream disconnect/unsubscribe. So I don't want to use the sync closed method because when should I check it? and dont' want to only drop subscription on failed to send because that will just be a waste of resources on both proxy server and upstream server. |
Yeah, that makes sense we should provide an async function that returns once this connection is closed or subscription is canceled. It's useful for folks to build their own async primitives instead of using My PR #962 will enable that. |
Closed by #962 We have now introduced |
jsonrpsee/core/src/server/rpc_module.rs
Line 828 in dab1bfc
I can't find any public API to expose this to allow me cleanup resources on drop connection. Also no public API to notify unsubscribe as well.
The text was updated successfully, but these errors were encountered: