0

首先,我想说我是 senecajs 的新手。

我正在测试这个配置。

我已经配置了在端口 9007 上运行的 Senecjs 微服务,该微服务正在正确运行并处理请求。当我直接请求此服务时,我会在 cca 10 秒后收到响应(它是对 oracle db 数据的请求)。

但是当我通过 Hapi + Seneca-web 请求相同的数据时,我收到此错误:“statusCode”:504,“error”:“Gateway Time-out”

["client","invalid_origin",{"port":9007,"pin":"mc:bankgtw","pg":"mc:bankgtw","type":"web","id":"pg:mc:bankgtw,pin:mc:bankgtw,port:9007","role":"transport","hook":"client","plugin$":{"name":"client$"},"fatal$":true,"meta$":{"mi":"wbn8u45tb7uh","tx":"o3f8eyia3f4n","id":"wbn8u45tb7uh/o3f8eyia3f4n","pattern":"hook:client,role:transport,type:web","action":"(q1yytemztu3k)","plugin_name":"transport","plugin_tag":"-","prior":{"chain":[],"entry":true,"depth":0},"start":1487199713842,"sync":true},"tx$":"o3f8eyia3f4n","host":"0.0.0.0","path":"/act","protocol":"http","timeout":5555,"max_listen_attempts":11,"attempt_delay":222,"serverOptions":{}},{"kind":"res","res":null,"error":{"isBoom":true,"isServer":true,"output":{"statusCode":504,"payload":{**"statusCode":504,"error":"Gateway Time-out**","message":"Client request timeout"},"headers":{}}},"sync":true,"time":{"client_recv":1487199799177}}] 

微服务返回数据前几秒。

这是我的配置:

const Hapi = require('hapi');
const Seneca = require('seneca');
const SenecaWeb = require('seneca-web');

const config = {
  adapter: require('seneca-web-adapter-hapi'),
  context: (() => {
    const server = new Hapi.Server();
    server.connection({
      port: 3001,
      routes: {
            cors: true,
            payload:{timeout:60000},
            timeout:{server: 60000, socket:90000}
        }
    });

    server.route({
      path: '/routes',
      method: 'get',
      handler: (request, reply) => {
        const routes = server.table()[0].table.map(route => {
          return {
            path: route.path,
            method: route.method.toUpperCase(),
            description: route.settings.description,
            tags: route.settings.tags,
            vhost: route.settings.vhost,
            cors: route.settings.cors,
            jsonp: route.settings.jsonp,
            server: server.info
          }
        })
        reply(routes)
      }
    });

    return server;
  })()
};

const seneca = Seneca({timeout: 99999})
  .use(SenecaWeb, config)
  .use(require('./hapi_api.js'))
  .client({ port:9007,  pin:'mc:bankgtw' })
  .ready(() => {
    const server = seneca.export('web/context')();
    server.start(() => {
      server.log('server started on: ' + server.info.uri);
    });
  });

我做错了什么或者什么超时导致了这个?

4

1 回答 1

1

我遇到了同样的问题,已解决,但它的做法非常糟糕。

转到 seneca-transport 文件夹中的“transport.js”。您将看到“超时:5555”继续并将其更改为您需要的任何内容。

我不确定为什么这没有获得 USER 默认值。据我所知,这是指客户端超时。确保您仍然使用服务器超时。

于 2017-06-14T15:02:34.763 回答