0

The sentence from the documentation of graphql-ws has put me in a difficulty in my project.

If there is already an active subscriber for an operation matching the provided ID, regardless of the operation type, the server must close the socket immediately with the event 4409: Subscriber for <unique-operation-id> already exists.

I think it means that should use 'unique-operation-id' to determine whether to send the 4409 event.

And I have examined the source code of graphql-dgs-spring-webflux-autoconfigure.com.netflix.graphql.dgs.webflux.handlers.WebsocketGraphQLTransportWSProtocolHandler and graphql-dgs-subscriptions-websockets.com.netflix.graphql.dgs.subscriptions.websockets.WebsocketGraphQLTransportWSProtocolHandler respectively. I found that the places where the decision to send the 4409 event is made have some slight differences.

In graphql-dgs-subscriptions-websockets, it seems that the decision to send the 4409 event(at line 128) is indeed made using the 'unique-operation-id' to determine whether to send the event. However, in graphql-dgs-spring-webflux-autoconfigure, it seems that the same decision(at line 92) is made using the WebSocket session ID to determine whether to send the event.

I would like to know why there is such a difference between the two.

In my project, I am using 'graphql-dgs-webflux-starter', so naturally my 'WebsocketGraphQLTransportWSProtocolHandler' is using 'graphql-dgs-spring-webflux-autoconfigure'. And in my schema, there are two or more entry points for subscriptions. If the frontend uses two or more entry points simultaneously, it will receive the 4409 event, even if only one WebSocket connection is established.

Is there any way to prevent receiving the 4409 event and use WebSocket normally to receive data?

Jumple
  • 25
  • 4

0 Answers0