graphql / graphql-playground

🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
MIT License
8.75k stars 730 forks source link

subscription websocket connection failed in graphql but works locally and with frontend application. #1329

Closed saurav-bhagat closed 3 years ago

saurav-bhagat commented 3 years ago

This issue pertains to the following package(s):

What OS and OS version are you experiencing the issue(s) on?

Windows 10

What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?

"graphql-playground-middleware-express": "1.7.18",

What is the expected behavior?

Subscription Websocket connection should be made with the server using the playground.

What is the actual behavior?

WebSocket is closed before the connection is established (From the network tab) Could not connect to websocket endpoint wss:///subscription. Please check if the endpoint url is correct

What steps may we take to reproduce the behavior?

I'm using Apollo server express ("2.18.2") with subscription endpoint as "/subscription". This works fine in the localhost playground. I deployed the application in my EKS cluster and now tried to make subscription connection to server with my react application and it worked as expected but when I open playground, I'm unable to connect to subscription. All normal queries and mutations are working fine from the playground. Just the websocket connection.

In Apollo client I have passed, reconnect: true as option, is there any similar option for playground? What could be the issue?

saurav-bhagat commented 3 years ago

This was really strange, my browser cache, I tried using a different browser and it worked. Apology for the inconvenience.

stvreumi commented 3 years ago

Thank you for reporting this issue. I recently learn how to use subscription, but I can't use the playground on my brave browser to connect to the server I just created. Even the apollo example in the document can't work. Then I saw this issue and change my browser to firefox, it works...