Closed shunsukew closed 2 months ago
As a background, software that proxying subscriptions (for e.g. Subway), proxy silently stop sending responses to clients when upstream ws connection is disconnected.
To avoid such situation, what I came up with are
Hey @shunsukew
Is it possible to disconnect ws connection from server side by using jsonrpsee api?
There is no dedicated API in jsonrpsee for the server-side the close down connections but it's possible to use to the low-level API with rpc middleware (which is a bit complicated to use)
There is a similar issue regarding this https://github.com/paritytech/jsonrpsee/issues/1427
When talking about subscriptions specifically I just want clarify that a few options exist to inform the client without closing the connection:
Subscription::reject
which just returns an error the origin RPC callHello, Thank you for the information!
Reject the subscription i.e, call Subscription::reject which just returns an error the origin RPC call
I was looking for a way to disconnect after accepting.
Send a special "error notification" or "application specific notification" before closing down subscription
In our usecase, just proxying standard subscribe calls (e.g. eth_subscribe
newHeads
), quite hard to add custom error notification, client sdk doesn't understand it because it's not eth/substrate standards.
Thank you for the sharing low level apis! I think this is the only way to disconnect after accepting PendingSubscription
.
For now, we have 2 different ws connection (client <> proxy and proxy <> upstream), and decided to re-subscribe after re-established the upstream connection, while keeping client side ws connection stay connected.
Possibly, will find a way to use those low level apis to disconnect connection itself.
Is it possible to disconnect ws connection from server side by using jsonrpsee api?
What I'm thinking of is disconnect ws connection from server side (not from client side) under specific situations.