1

I'm currently using Lighthouse as the graphql server for laravel. I've worked through the subscription documentation (https://lighthouse-php.com/master/subscriptions/getting-started.html) on their site, as well as added the appropriate pusher credentials to the .env file.

When attempting to subscribe via the graphql-playground UI, I'm getting the following error:

subscription:

subscription {
  orgUserCreated {
    org
  }
}

error:

{
  "error": "Could not connect to websocket endpoint ws://localhost:8000/graphql. Please check if the endpoint url is correct."
}

All mutations and queries are working as they should.

I've overridden the index.blade.php file for the laravel-graphql-playground laravel and can add a "subscriptionEndpoint" variable to that file, but it's unclear what that variable should contain.

<script type="text/javascript">
  window.addEventListener('load', function (event) {
    const loadingWrapper = document.getElementById('loading-wrapper');
    loadingWrapper.classList.add('fadeOut');
    const root = document.getElementById('root');
    root.classList.add('playgroundIn');
    GraphQLPlayground.init(root, {
      endpoint: "{{url(config('graphql-playground.endpoint'))}}",
      subscriptionEndpoint: "?"
    })
  })
</script>

Does anyone know what should be contained in the "subscriptionEndpoint" variable since I'm connecting via pusher?

Joseph Williams
  • 85
  • 1
  • 15

2 Answers2

2

For future reference, I had to use the following:

wss://ws-[CLUSTER].pusher.com:443/app/[APP_KEY]?protocol=5
ws://ws-[CLUSTER].pusher.com:80/app/[APP_KEY]?protocol=5

[CLUSTER] can be found on pusher, mine was "eu"

[APP_KEY] not App ID, but the public key

Gregory
  • 1,148
  • 1
  • 9
  • 24
1

The subscription endpoints for Pusher Channels are as follows (substituting 'you-cluster' for the cluster where your Channels app resides):

ws://ws-[your-cluster].pusherapp.com on port 80

wss://ws-[your-cluster].pusherapp.com on port 443

You can see more information below:

https://pusher.com/docs/channels/miscellaneous/clusters#what-clusters-exist-

https://support.pusher.com/hc/en-us/articles/360019420773-What-ports-do-I-need-to-open-in-my-Firewall-to-allow-Channels-to-connect-

Chris C
  • 461
  • 2
  • 6