Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graphql 仅通过https在长查询上获取502错误_Graphql_Google Kubernetes Engine_Grpc_Apollo Server - Fatal编程技术网

Graphql 仅通过https在长查询上获取502错误

Graphql 仅通过https在长查询上获取502错误,graphql,google-kubernetes-engine,grpc,apollo-server,Graphql,Google Kubernetes Engine,Grpc,Apollo Server,我在gql服务器上有一个相当长的查询,解析器调用一个grpc方法。当我在本地运行它时,它可以工作,但是当我对我们的开发部署(https)进行查询时,请求会返回 <html><head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>502 Server Error</title> </head> <body text=

我在gql服务器上有一个相当长的查询,解析器调用一个grpc方法。当我在本地运行它时,它可以工作,但是当我对我们的开发部署(https)进行查询时,请求会返回

<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>502 Server Error</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Server Error</h1>
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.</h2>
<h2></h2>
</body></html>
我的服务器

const server = new ApolloServer({
  typeDefs: schema,
  resolvers,
  context: async ({ req, connection}) => {
    if(req){
      return {
        req,
      };
    }
  },
});


server.applyMiddleware({ app, path: '/graphql' });
const httpServer = http.createServer(app);
server.installSubscriptionHandlers(httpServer);
httpServer.listen({ port: 8001 }, () => {
  console.log('Apollo Server on http://localhost:8001/graphql');
});

请求运行多长时间?连接很可能提前关闭,通常应该是504,但这可能是由于连接的终止方式。@HMilbradt非常可靠,正好30秒。根据问号,这似乎是在GKE上运行的。此外,502代码通常与中继请求和网络问题的资源相关联。包括涉及的Kubernetes对象定义可能很重要,以确定错误是否来自错误配置。这似乎是Apollo服务器的问题,一旦进行了大型查询(需要返回大量字段)(可能只有在负载较大的情况下,我测试过),Apollo服务器才会返回502,这些问题只发生在我的集群(也是GKE)上的GraphQL服务上,没有一个非GraphQL服务遇到同样的问题,即使是在高负载的情况下也是如此?连接很可能提前关闭,通常应该是504,但这可能是由于连接的终止方式。@HMilbradt非常可靠,正好30秒。根据问号,这似乎是在GKE上运行的。此外,502代码通常与中继请求和网络问题的资源相关联。包括涉及的Kubernetes对象定义可能很重要,以确定错误是否来自错误配置。这似乎是Apollo服务器的问题,一旦进行了大型查询(需要返回大量字段)(可能只有在负载较大的情况下,我测试过),Apollo服务器才会返回502,这些只发生在我集群(也是GKE)上的GraphQL服务上,没有一个非GraphQL服务遇到同样的问题,即使是在高负载的情况下。
const server = new ApolloServer({
  typeDefs: schema,
  resolvers,
  context: async ({ req, connection}) => {
    if(req){
      return {
        req,
      };
    }
  },
});


server.applyMiddleware({ app, path: '/graphql' });
const httpServer = http.createServer(app);
server.installSubscriptionHandlers(httpServer);
httpServer.listen({ port: 8001 }, () => {
  console.log('Apollo Server on http://localhost:8001/graphql');
});