如果设置为 20 秒或更长时间,则使用 keepAlive 会出现问题

Dan*_*odd 5 node.js apollo graphql

对于 Apollo 订阅的 keepAlive 有一些麻烦。每当我将时间设置为秒或更长时间时,监听订阅就会出错。

{
  "error": "Could not connect to websocket endpoint ws://website.test:8000/graphql. Please check if the endpoint url is correct."
}
Run Code Online (Sandbox Code Playgroud)

这是 ApolloServer 设置

const apollo = new ApolloServer({
    introspection: true,
    playground: true,
    typeDefs: schema,
    subscriptions: {
      keepAlive: 40000,
    },
    resolvers,
    context: ........
}
Run Code Online (Sandbox Code Playgroud)

在我的本地环境中,当我没有设置 keepAlive 时,它​​将无限期地保持打开状态。如果我将它设置为 10000 效果很好。保持活动设置为 40000 我收到错误并且连接关闭

更新我们刚刚注意到的一件事是这个问题发生在操场上,而不是我们的网络应用程序上。也许只是一个游乐场?

Eli*_*ias 0

如果没有,如果这些有帮助,我建议你在 Apollo 存储库上打开一个问题: