ibm-watson node-sdk всегда возвращает ошибку 503 service unavailable error для watson assistant v1 - PullRequest
0 голосов
/ 07 мая 2020

Node version 10.16.0

ibm-watson version ^ 5.5.0

Node.js код для подключения к Watson Assistant. Обращено https://cloud.ibm.com/apidocs/assistant/assistant-v1

const AssistantV1 = require('ibm-watson/assistant/v1');
const { BasicAuthenticator } = require('ibm-watson/auth');
const { IamAuthenticator } = require('ibm-watson/auth');

const HttpsProxyAgent = require('https-proxy-agent'); // https Agent
const httpsAgent = new HttpsProxyAgent("my proxy url");

const assistant = new AssistantV1({
    version: '2018-09-20',
    authenticator: new BasicAuthenticator({
        username: 'apikey',
        password: 'my password',
        disableSslVerification: true
    }),
    url: 'https://api.eu-de.assistant.watson.cloud.ibm.com',
    httpsAgent
});

const params = {
    workspaceId: 'my workspace id',
};

assistant.listIntents(params)
    .then(res => {
        console.log(JSON.stringify(res, null, 2));
    })
    .catch(err => {
        console.log(err)
    });

Я всегда получаю следующую ошибку:

C:\James\bitbucket\codebase>node watsonV1
{ Service Unavailable: Service Unavailable
    at RequestWrapper.formatError (C:\James\bitbucket\codebase\node_modules\ibm-watson\node_modules\ibm-cloud-sdk-core\lib\request-wrapper.js:216:21)
    at C:\James\bitbucket\codebase\node_modules\ibm-watson\node_modules\ibm-cloud-sdk-core\lib\request-wrapper.js:204:25
    at process._tickCallback (internal/process/next_tick.js:68:7)
  statusText: 'Service Unavailable',
  name: 'Service Unavailable',
  status: 503,
  code: 503,
  message: 'Service Unavailable',
  body:
   '"<HTML><HEAD>\\r\\n<TITLE>Network Error</TITLE>\\r\\n</HEAD>\\r\\n<BODY>\\r\\n<FONT face=\\"Helvetica\\">\\r\\n<big><strong></strong></big><BR>\\r\\n</FONT>\\r\\n<blockquote
>\\r\\n<TABLE border=0 cellPadding=1 width=\\"80%\\">\\r\\n<TR><TD>\\r\\n<FONT face=\\"Helvetica\\">\\r\\n<big>Network Error (tcp_error)</big>\\r\\n<BR>\\r\\n<BR>\\r\\n</FONT>\\
r\\n</TD></TR>\\r\\n<TR><TD>\\r\\n<FONT face=\\"Helvetica\\">\\r\\nA communication error occurred: \\"\\"\\r\\n</FONT>\\r\\n</TD></TR>\\r\\n<TR><TD>\\r\\n<FONT face=\\"Helvetica
\\">\\r\\nThe Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.\\r\\n</FONT>
\\r\\n</TD></TR>\\r\\n<TR><TD>\\r\\n<FONT face=\\"Helvetica\\" SIZE=2>\\r\\n<BR>\\r\\nFor assistance, contact your network support team.\\r\\n</FONT>\\r\\n</TD></TR>\\r\\n</TABL
E>\\r\\n</blockquote>\\r\\n</FONT>\\r\\n</BODY></HTML>\\r\\n"',
  headers:
   { 'cache-control': 'no-cache',
     pragma: 'no-cache',
     'content-type': 'text/html; charset=utf-8',
     'proxy-connection': 'close',
     connection: 'close',
     'content-length': '768' } }

Я также пробовал использовать «IamAuthenticator», как показано ниже. но та же ошибка.

const assistant = new AssistantV1({
    version: '2018-09-20',
    authenticator: new IamAuthenticator({
        apikey: 'my password',
        httpsAgent
    }),
    url: 'https://api.eu-de.assistant.watson.cloud.ibm.com',
    httpsAgent
});

Если я не использую httpsAgent, я получаю ошибку ниже.

C:\James\bitbucket\codebase>node watsonV1
{ Error: write EPROTO 6832:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:

    at RequestWrapper.formatError (C:\James\bitbucket\codebase\node_modules\ibm-watson\node_modules\ibm-cloud-sdk-core\lib\request-wrapper.js:216:21)
    at C:\James\bitbucket\codebase\node_modules\ibm-watson\node_modules\ibm-cloud-sdk-core\lib\request-wrapper.js:204:25
    at process._tickCallback (internal/process/next_tick.js:68:7)
  message:
   'write EPROTO 6832:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\\ws\\deps\\openssl\\openssl\\ssl\\record\\ssl3_record.c:332:\n',
  statusText: 'EPROTO',
  body:
   'Response not received - no connection was made to the service.' }

Он отлично работает, когда я использую модуль npm watson-developer- cloud, поскольку он устарел, я хочу использовать новый модуль ibm-watson.

...