等待流数据时Apollo Server超时

Tor*_*RTC 12 braintree node.js apollo graphql apollo-server

我正在尝试用我的Apollo Server等待流的结果.我的解析器看起来像这样.

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);
  }
},
Run Code Online (Sandbox Code Playgroud)

当返回的数据流很小时,这个解析器工作正常,但是当进入的数据较大时,我得到了一个503 (Service Unavailable).我看起来超时发生在30秒左右.我已经尝试过增加我的Express服务器的超时graphQLServer.timeout = 240000;但这并没有什么不同.

我怎样才能解决这个问题?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' } }
Run Code Online (Sandbox Code Playgroud)

dab*_*and 5

遇到同样的问题,这是一个非常简单的解决方案。我的通话持续了30秒多一点,默认超时也恢复了503s,所以我增加了。

假设您使用的是阿波罗引擎(某些其他形式的阿波罗可能是这样),则可以如下设置引擎配置:

  export function startApolloEngine() {
    const engine = new Engine({
    engineConfig: {
      stores: [
        {
          name: "publicResponseCache",
          memcache: {
            url: [environmentSettings.memcache.server],
            keyPrefix: environmentSettings.memcache.keyPrefix
          }
        }
      ],
      queryCache: {
        publicFullQueryStore: "publicResponseCache"
      },
      reporting: {
        disabled: true
      }
    },
    // GraphQL port
    graphqlPort: 9001,
    origin: {
      requestTimeout: "50s"
    },

    // GraphQL endpoint suffix - '/graphql' by default
    endpoint: "/my_api_graphql",
    // Debug configuration that logs traffic between Proxy and GraphQL server
    dumpTraffic: true
  });

  engine.start();
  app.use(engine.expressMiddleware());
}
Run Code Online (Sandbox Code Playgroud)

注意我指定的部分

origin: { requestTimeout: "50s" }

仅此一点对我来说就是固定的。希望这可以帮助!

您可以在此处找到有关信息的更多信息