0

Hasura GraphQL Engine is deployed on a Cloudfoundry instance backed by AWS, it is exposed at a subdomain via an AWS ELB. The console is exposed at https://hasura.cloud.domain.com/console and the GraphQL API accepts queries at https://hasura.cloud.domain.com/v1alpha1/graphql.

But when a subscription is executed from console, an error happens with the following log on JS Console:

vendor.js:1 WebSocket connection to 'wss://hasura.cloud.domain.com/v1alpha1/graphql' failed: Error during WebSocket handshake: Unexpected response code: 200

Analyzing the websocket frames on Chrome indicates an error with (Opcode -1).

Basically, the client is unable to open a websocket connection.

Shahidh
  • 2,472
  • 1
  • 18
  • 18

1 Answers1

0

Some load balancers do not support passing WebSocket handshake requests containing the Upgrade header to the CF router. For instance, the Amazon Web Services (AWS) Elastic Load Balancer (ELB) does not support this behavior. In this scenario, you must configure your load balancer to forward TCP traffic to your CF router to support WebSockets.

ref: https://docs.cloudfoundry.org/adminguide/supporting-websockets.html#config

Basically, there is some configuration required with AWS ELB and CF Router to get websockets working. This is typically done by setting up a non-standard port to forward all TCP connections to the CF Router. We have learned from our clients that this port is typically 4443.

So, to get websocket connections to work, choose the endpoint as wss://hasura.cloud.domain.com:4443/v1alpha1/graphql for websocket connections and thus subscriptions.

The console can be opened at https://hasura.cloud.domain.com:4443 as well.

Shahidh
  • 2,472
  • 1
  • 18
  • 18