-
Notifications
You must be signed in to change notification settings - Fork 717
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
WebSocketTransport: detect server side completion message. #3337
Comments
Hi @mkubista - what notification are you wanting to receive and where? The callback for a subscription event is in response to fetching a query so that callback should only be for new data, not termination of the socket. Similarly |
I needed anything, that would allow me to somehow react to the event, that subscription has been closed from the server side. On server side, there is a timeout for the data search. When it is passed, the server simply close the subscription as a signal, that there will be no further data updates. So on client the loading animation would disappear and Retry button will appear instead. But Right now, when Im in a little tight schedule, I solved it by in fact copy-pasting the I dont know, if it is the correct way, but server right for my purpose. |
I'm glad you've found a solution but as you're finding out there are hard limits to the current implementation of websockets and subscriptions. I am hesitant to make that kind of change in Version 2.0 is really where we'll improve everything networking and websocket subscriptions is in scope for that. |
Yes I know, that this solution is not very good. Some sort of delegate, which would provide subscriber state change, would be better, but with that, there would be needed some way, to propagate that to the subscriber point of origin anyway. But Im glad, that there is a Version 2.0 on the way. I will keep that in mind and will follow the progress. |
Question
Hi. I have a problem with configuring the WebSocketTransport for Graphql subscriptions. Im have successfully integrated WebSocket and WebSocketTransport into the project. Im able to create subscription. The web socket is being connected. Server is able to send me data and my client code is able to receive data.
The problem is, that when server wants to end subscription, it sends message
"{\"id\":\"1\",\"type\":\"complete\"}"
And nothing happens. Subscriber is not notified anyhow.In the WebSocketTransport I found out, that the
complete
message is in fact ignored, because thesubscriptions[id]
is nevernil
. Even if it would benil
thesubscriber
would be only removed from the internal storage and is not notified.I tried to hook up on the raw message closure
onText
inWebSocket
class. There Im able to detectcomplete
message, manually callunsubscribe
with apropriate subscriber ID. But again, it only removes it from handler store in transport.And I didnt find any straight forward option, how to notify that subscriber, that the server decided to end the subscription.
Only way would be to create my own storage for subscriber callback and implement custom
OperationMessageIdCreator
, because theWebSocketTask
is unaccessible. It isfinal
not public, so Im not able to accesssequenceNumber
Did I something wrong or there is in fact no simple way, to detect server side end of subscription?
The text was updated successfully, but these errors were encountered: