1

我目前使用 Lighthouse 作为 laravel 的 graphql 服务器。我已经阅读了他们网站上的订阅文档(https://lighthouse-php.com/master/subscriptions/getting-started.html),并将适当的推送器凭据添加到 .env 文件中。

尝试通过 graphql-playground UI 订阅时,出现以下错误:

订阅:

subscription {
  orgUserCreated {
    org
  }
}

错误:

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

所有突变和查询都在正常工作。

我已经覆盖了 laravel-graphql-playground laravel 的 index.blade.php 文件,并且可以向该文件添加一个“subscriptionEndpoint”变量,但不清楚该变量应该包含什么。

<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>

由于我通过推送器连接,有谁知道“subscriptionEndpoint”变量中应该包含什么?

4

2 回答 2

2

为了将来参考,我不得不使用以下内容:

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

[CLUSTER] 可以在 pusher 上找到,我的是“eu”

[APP_KEY] 不是 App ID,而是公钥

于 2020-01-31T13:17:44.780 回答
1

Pusher Channels 的订阅端点如下(将“you-cluster”替换为您的 Channels 应用程序所在的集群):

ws://ws-[your-cluster].pusherapp.com在 80 端口上

wss://ws-[your-cluster].pusherapp.com在端口 443

您可以在下面看到更多信息:

https://pusher.com/docs/channels/miscellaneous/clusters#what-c​​lusters-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-

于 2019-08-02T16:13:31.943 回答