Unable to connect to Dgraph Cloud via WebSocket

I am using React + Relay framework which suggests using graphql-ws to establish the websocket connection for subscriptions.

I am able to query and mutate objects in Dgraph Cloud just fine so far, but wanted to begin testing out subscriptions which require a websocket connection.

I am getting an error message when attempting to make the connection, and I’m having a hard time telling where the issue is. I suspect I’m doing something wrong when attempting to connect to Dgraph Cloud via websocket, but I’m only on the free tier (still testing things out) so I don’t have access to the Access Log to be able to get any more information from the Dgraph side.

Here is my relevant bit of code:

import { createClient } from 'graphql-ws';
const wsClient = createClient({
  url: 'wss://*****.us-west-2.aws.cloud.dgraph.io/graphql'
});

To take Relay out of the equation, I’ve also tried using a few other methods of connecting all with the same results. The most reproducible method I suppose would be this chrome extension. Where I just get a generic error message:
WebSocket connection to 'wss://*****.us-west-2.aws.cloud.dgraph.io/graphql' failed

I have found a few docs that show connecting via the apollo client, admittedly I have not tried that, but I don’t think the client I’m using is really relevant. I think the issue lies somewhere else, or the address I’m attempting to connect to. Do free tier clusters even support websockets?

Dgraph only supports the deprecated version:

subscription-transport-ws

J

1 Like

Thanks, I didn’t even try that since it’s deprecated, but It appears to be working. I’m at least not getting any errors about failed connection anymore. After I get subscriptions working, I may opt not to use them anyway due to some of the concerns outlined in the discussion you posted.