接收从Node.JS到Azure事件中心的HTTPS请求的ECONNRESET错误
我目前有一个Node.js Web API,它将HTTPS请求发送到Azure事件中心。 如果我发送单个请求或小的突发(5-7),集线器收到罚款。 但是,如果我尝试发送比这更多的信息,那么我将会收到来自集线器的ECONNRESET
错误,这个错误超过了ECONNRESET
(第一个ECONNRESET
将通过罚款)。 (7是不是一个硬数字,它从testing到testing,但似乎是在附近)
我有一个JSON对象的数组,我通过下面的代码发送到集线器:
for (var i in stack) { var obj = stack[i]; sendPayloadToEventHub(JSON.stringify(obj)); }
将JSON发送到事件中心的代码:
sendPayloadToEventHub = function (payload) { var options = { hostname: config['namespace'] + '.servicebus.windows.net', port: 443, path: '/' + config['hubname'] + '/publishers/' + config['devicename'] + '/messages', method: 'POST', headers: { 'Authorization': returnSASToken(), 'Content-Length': payload.length, 'Content-Type': 'application/atom+xml;type=entry;charset=utf-8' } }; // create the request object with the set options var req = https.request(options, function (res) { res.on('data', function (d) { process.stdout.write(d); }); res.on('end', function () { console.log('log complete....'); }); }); // Error Handle req.on('error', function (e) { console.error('HTTPS error: ' + e); }); // Deliver the payload and end the request req.write(payload); req.end(); };
我收到HTTPS error: Error: read ECONNRESET
的输出HTTPS error: Error: read ECONNRESET
未能传递的消息的HTTPS error: Error: read ECONNRESET
。
该数组可以有任何数量的JSON对象,所以我需要能够发送不同数量的突发。 我曾尝试在循环中添加睡眠延迟,但是没有解决这个问题。
有谁知道可能是什么原因造成的?
这个错误是由于一些JSON对象的payload.length
不能正确计算的结果。 确定计算后,错误停止。
- 从GitHub到Azure的Travis CI部署返回! HEAD – > master(浅度更新不允许)
- Socket.io + Azurenetworking套接字问题
- 在azure node.js工作者angular色上定制性能计数器
- 使用Azure node.js SDK的createContainerIfNotExist方法进行AuthenticationFailed
- 如何在azure网站子目录中运行node.js应用程序
- 哪个azure色的选项适合我的使用node.js的TCP游戏服务器?
- 我可以托pipeMS Bot框架Node.js实例本地
- Visual Studio发布button被禁用?
- Azure copyBlob Node.js API错误