【问题标题】:Unable to call watson language translator using proxy无法使用代理调用 watson 语言翻译器
【发布时间】:2019-07-16 16:37:06
【问题描述】:

当我通过公共网络调用 watson 语言翻译服务时,它的响应没有错误。同时,它无法通过我的专用网络获取响应正文

我正在使用 NGINX 有我的负载均衡器,并在配置中为其配置了 proxy_http。

错误是

{ 错误:未收到响应。错误主体是 HTTP ClientRequest 对象 在 formatError (root\node_modules\ibm-cloud-sdk-core\lib\requestwrapper.js:115:17) 在 D:\Rafiki Project\production build\Rafiki Production Files 1\ecobot-orchestrator-master_23_9-orch_persistency_fixes\node_modules\ibm-cloud-sdk-core\lib\requestwrapper.js:265:19 在 process._tickCallback (internal/process/next_tick.js:68:7)

var languageTranslator = new LanguageTranslatorV2({
  username:'8******************',
  password:'*************',
  url: 'https://gateway.watsonplatform.net/language-translator/api/',
  version: '2017-05-26'
});

function translateToWSPLan(req, res, callback){
  console.log("the request for translation is::");
  console.log(JSON.stringify(req));
  console.log("======================");
  languageTranslator.identify(req.body.identifyParams, function(err, data){
    if(err){
      console.log('=================error==========');
      console.log(err);
      console.log('=================================');
      var errorLog = {name: err.name, message: err.message};
      callback(errorLog);
    }else {

    }
})

【问题讨论】:

  • 如果上面的代码适用于公共网络,那么它与您的私有网络的配置有关。请分享该配置和其他相关详细信息。

标签: nginx ibm-watson nginx-location watson-assistant


【解决方案1】:

查看 Node.js SDK for Watson 上提出的这个问题 - https://github.com/watson-developer-cloud/node-sdk/issues/900#issuecomment-509257669

要启用代理路由,请将代理设置添加到构造函数



var languageTranslator = new LanguageTranslatorV2({
  username:'8******************',
  password:'*************',
  url: 'https://gateway.watsonplatform.net/language-translator/api/',
  version: '2017-05-26',
  // other params...
  proxy: '<some proxy config>',
  httpsAgent: '<or some https agent config>'
});


如果您查看该问题,则访问 IAM 令牌时存在问题,该问题在有代理时不起作用,但由于您似乎使用的是用户 ID/密码组合,您应该没问题。直到云边界样式凭证被暂停并被所有现有 Watson 服务的 IAM 凭证取代。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-21
    • 2014-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-21
    相关资源
    最近更新 更多