【发布时间】:2018-09-11 15:30:14
【问题描述】:
我在我的应用程序中使用 Express.js,向 adobe 分析 API 发出发布请求时出现错误。
我尝试添加server.timeout,但没有解决它...
这是错误信息:
错误:读取 ECONNRESET
在exports._errnoException (util.js:1028:11)
在 TLSWrap.onread (net.js:572:26) 代码:'ECONNRESET',errno:'ECONNRESET',系统调用:'read'
这是失败的代码:
pullClassifications(req) {
const dfd = q.defer();
const { username, password, payload } = req;
const data = wsse({username: username, password: password});
const wsseHeaders = {'X-WSSE': data.toString({ nonceBase64: true })};
const options = {
'method': 'post',
'headers': wsseHeaders,
'content-type': 'application/json',
'body': payload,
'json': true,
'url': 'https://api.omniture.com/admin/1.4/rest/?method=ReportSuite.GetClassifications'
}
request(options, function(err, response, body) {
if(response.statusCode == 200) {
dfd.resolve(body);
} else {
dfd.reject({statusCode: response.statusCode, body: body});
}
})
return dfd.promise;
}
更新:
我尝试使用 Postman 发布相同的请求,它可以工作,在 630000 毫秒内返回响应。
这个错误的原因是什么,有什么办法可以解决吗?
【问题讨论】:
-
该错误可能与 Node.js/https 模块无关。我建议你在 Node.js 之外尝试一下(例如使用 curl 或 Postman 之类的东西)
-
@fardjad 我尝试使用 Postman 并且它有效。总时间为 630000ms
-
这似乎是 API 方面的问题
-
@RenatoGama 但为什么它使用 Postman 工作?
-
这里有同样的问题。适用于邮递员,但不适用于我的后端。
标签: node.js express post econnreset