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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gateway] Websocket subprotocol isn't forwarded to the endpoint #8324

Closed
gaetanmaisse opened this issue Aug 17, 2022 · 1 comment
Closed

Comments

@gaetanmaisse
Copy link
Contributor

馃挜 Describe the bug

Websocket subprotocol isn't forwarded to the endpoint causing a 502 error when trying to connect.

馃寗 To Reproduce

Steps to reproduce the behaviour:

  1. Clone https://github.com/apollographql/docs-examples/tree/main/apollo-server/v3/subscriptions-graphql-ws
  2. Go inside the directory and run yarn && yarn start, it will start the WS server on: ws://localhost:4000/graphql
  3. Using Postman you should be able to connect to ws://localhost:4000/graphql, set the header Sec-WebSocket-Protocol: graphql-transport-ws and send the following message (within 3s otherwise you will be disconnected):
{ 
  "type": "connection_init" 
}

You will receive:

{ 
  "type": "connection_ack" 
}
  1. Activate Websocket in the gravitee.yml of the gateway:
http:
  websocket:
    enabled: true
    subProtocols: graphql-transport-ws
    perMessageWebSocketCompressionSupported: true
    perFrameWebSocketCompressionSupported: true
  1. On Gravitee APIM, create an API with ws://localhost:4000/graphql as a backend endpoint
  2. Try to connect to it using the same method as in 3.
  3. 馃挜 You will receive an error: Error: Unexpected server response: 502

馃寛 Expected behaviour

Unable to connect, graphql-transport-ws protocol isn't forward

Current behaviour

The connection should be ok

馃敆 Dependencies

Also related to #8228

@gaetanmaisse
Copy link
Contributor Author

Tested on 3.15.x, it looks ok, subprotocol is now handled. But it appears that connecting to WS server behind a redirection isn't easy... it's working with Postman but wasn't able to connect using curl, ws, wscat 馃し馃徎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants