botbuilder-js: Random ECONNRESET

Versions

NodeJS v12.13.0 BotBuilder NodeJS SDK v4.8.0

Describe the bug

In production for directline channel users, our bot is giving random ECONNRESET errors, and we are not able to reproduce it, because it is really random. It is one example of the error:

(node:13008) UnhandledPromiseRejectionWarning: Error: BotFrameworkAdapter.processActivity(): 500 ERRORError: read ECONNRESETat new RestError (D:\home\site\wwwroot\node_modules\botframework-connector\node_modules\@azure\ms-rest-js\dist\msRest.node.js:1397:28)at AxiosHttpClient.<anonymous> (D:\home\site\wwwroot\node_modules\botframework-connector\node_modules\@azure\ms-rest-js\dist\msRest.node.js:1550:35)at step (D:\home\site\wwwroot\node_modules\tslib\tslib.js:139:27)at Object.throw (D:\home\site\wwwroot\node_modules\tslib\tslib.js:120:57)at rejected (D:\home\site\wwwroot\node_modules\tslib\tslib.js:111:69)at runMicrotasks (<anonymous>)at processTicksAndRejections (internal/process/task_queues.js:93:5)at BotFrameworkAdapter.<anonymous> (D:\home\site\wwwroot\node_modules\botbuilder\lib\botFrameworkAdapter.js:660:27)at Generator.throw (<anonymous>)at rejected (D:\home\site\wwwroot\node_modules\botbuilder\lib\botFrameworkAdapter.js:12:65)at runMicrotasks (<anonymous>)at processTicksAndRejections (internal/process/task_queues.js:93:5)(node:13008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)(node:13008) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It happens like 20-30 times a day. I have checked this issue:

https://github.com/microsoft/botbuilder-js/issues/1705

But it was closed with no solution, so I have opened another one.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (14 by maintainers)

Most upvoted comments

It is possible to provide a custom http client with the 1.2.6 version of ms-rest-js used in the sdk:

const customHttpClient = new customHttpClient();
BotFrameworkAdapter.prototype.createConnectorClientInternal = function (serviceUrl, credentials) {
    return new ConnectorClient(credentials, { baseUri: serviceUrl, httpClient: customHttpClient });
};

It might be easiest to just duplicate this class: axiosHttpClient and change line 19:

axios.create({
  httpAgent: new http.Agent({ keepAlive: true }),
  httpsAgent: new https.Agent({ keepAlive: true }),
});

As @mdrichardson mentioned, we are working on upgrading the sdk’s version of ms-rest-js, and overcoming port exhaustion should be easier then.