graphql - 仅通过 https 进行长查询时出现 502 错误
问题描述
我的 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');
});
解决方案
推荐阅读
- kendo-ui - How to start kendo pdf viewer with 'FitToWidth' selected
- flutter - 打破 ForEach() 飞镖
- highcharts-editor - Can't set 'stops' values in highcharts editor
- android - Android BroadcastReceiver OnReceieve not hit
- reactjs - 如何使用 React.js 正确显示 JSON 记录的所有子值
- php - 限制没有变量的页面,仅在来自页面或站点时打开
- javascript - 如何使用 Websockets 连接到 MQTT 代理?
- java - 如何在迭代流期间使用丰富(外部)调用?
- regex - 如何使用 sed 和 Regex 在 Bash 中突出显示语法?
- reactjs - 在 React 中更改状态会导致 Azure SignalR 出现错误 429