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

How to know subscription state #3344

Open
arnauddorgans opened this issue Feb 22, 2024 · 1 comment
Open

How to know subscription state #3344

arnauddorgans opened this issue Feb 22, 2024 · 1 comment
Labels
apollo-websockets feature New addition or enhancement to existing solutions networking-stack question Issues that have a question which should be addressed

Comments

@arnauddorgans
Copy link

Question

Hi

Is there a way to know the current state or listen to the state change of a subscription?

Sometimes, I feel that after a socket disconnection, there is a delay between the actual resubscription, and I would like to make sure that a specific subscription is currently listening or reconnecting, etc..

@arnauddorgans arnauddorgans added the question Issues that have a question which should be addressed label Feb 22, 2024
@calvincestari
Copy link
Member

Hi @arnauddorgans - there unfortunately isn't any way to get the status of a single subscription.

The current implementation is very naive with regards to it's implementation of subscribers. There is a list of subscribers keyed by an identifier with no state being stored about the subscriptions. I suppose if a subscriber identifier is in that list it could be considered 'open' but for identifiers that are not present we'd have no idea if that had even a valid identifier so it would be incorrect to return 'closed' when it could have been 'never existed'.

There is probably a hacky solution we could implement to enable this for now but 2.0 is really where we'll improve everything networking.

WebSocketTransportDelegate will give you connection events for WebSocketTransport so you could use this as a sort of proxy indicator if you only have a single subscription, but if you use the same websocket transport for multiple subscriptions then that will not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apollo-websockets feature New addition or enhancement to existing solutions networking-stack question Issues that have a question which should be addressed
Projects
None yet
Development

No branches or pull requests

3 participants