【发布时间】:2018-07-07 12:03:19
【问题描述】:
我正在尝试使用我的 Apollo 服务器等待流的结果。我的解析器看起来像这样。
async currentSubs() {
try {
const stream = gateway.subscription.search(search => {
search.status().is(braintree.Subscription.Status.Active);
});
const data = await stream.pipe(new CollectObjects()).collect();
return data;
} catch (e) {
console.log(e);
throw new Meteor.Error('issue', e.message);
}
},
当返回的数据流较小时,此解析器工作得很好,但是当传入的数据较大时,我得到一个503 (Service Unavailable)。我看起来超时发生在 30 秒左右。我尝试使用graphQLServer.timeout = 240000; 增加我的 Express 服务器的超时时间,但这并没有什么不同。
如何解决此问题以及 30 秒超时来自何处?只有当结果需要更长的时间时才会失败。
我正在使用https://github.com/mrdaniellewis/node-stream-collect 从流中收集结果。
try catch 进来的错误:
I20180128-13:09:26.872(-7)? { proxy:
I20180128-13:09:26.872(-7)? { error: 'Post http://127.0.0.1:26474/graphql: net/http: request canceled (Client.Timeout exceeded while awaiting headers)',
I20180128-13:09:26.872(-7)? level: 'error',
I20180128-13:09:26.873(-7)? msg: 'Error sending request to origin.',
I20180128-13:09:26.873(-7)? time: '2018-01-28T13:09:26-07:00',
I20180128-13:09:26.873(-7)? url: 'http://127.0.0.1:26474/graphql' } }
【问题讨论】:
-
您能否详细介绍一下您的基础架构? Apollo 服务器是直接连接的,还是在负载均衡器或代理或反向代理或类似的东西后面?
-
您增加超时的方式不正确。你是如何启动你的服务器的,你使用的是 apollo-engine 还是 apollo-server 或 apolloExpress 等 :)
-
@JoeWarner 我通过github.com/apollographql/meteor-integration使用apollo-server v1
标签: node.js graphql braintree apollo apollo-server