我在我的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>
还有其他可以通过https进行的grpc调用。所以我认为那没什么问题。
在gcp日志中,我实际上可以看到记录的解析程序的结果。尽管在浏览器中是502错误。
我的解析器
train: async (parent, args) => {
const { projectId, yml } = args
let result = await nluTrain(projectId, yml);
return { done:result }
}
我的服务器
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');
});