How to subscribe to Slash GraphQL in the correct way, getting 301 error

So I have been trying to subscribe to Slash GraphQL, but I am getting a 301 error:

WebSocket connection to ‘ws://******-d.ap-south-1.aws.cloud.dgraph.io/graphql’ failed: Error during WebSocket handshake: Unexpected response code: 301

I am using Apollo client along with all the subscription-related config done, please note that the first time when the subscription gets initialized, all the data I am getting is perfect, but after that, all my WS requests are responding with a status code of 301. Any help would be highly appreciated. Thanks.

2 Likes

can you follow this tutorial to setup subscription and check if your problem still exists ?

@mbj36 Thanks for the help, I figured out from the example that I have to use the “wss://” protocol instead of “ws://”, I changed the same and now it is working perfectly. Thanks again.

2 Likes

Thanks for updating with your solution! I ran into this problem while I was following a Dgraph tutorial. Specifically this bit of code graphql-sample-apps/index.js at c0b4e09045abe6db6d0981a2f6e531498596c2a9 · dgraph-io/graphql-sample-apps · GitHub