[英]connect ETIMEDOUT Node.js
我在Auth0委派管理擴展中使用了一個create hook
。
我在觸發create hook時收到此錯誤:
Error: connect ETIMEDOUT xxx.xxx.xxx.xxx:8081
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
創建Hook功能是:
function(ctx, callback) {
var request = require('request');
// Perform any asynchronous actions
var API_URL = "https://example.com:8081/api/saveData";
var empFirstName = 'Jhone';
var empId = '123';
request.post({
url: API_URL,
json: {
firstName: empFirstName,
userId: empId
}
},
function(error, response, body) {
if (error) {
ctx.log('Create failed to '+API_URL+':', error);
return callback(new Error('Something went wrong. Please try again.'));
}
ctx.log('Create successful! Server responded with:', body);
return callback(null, {
/*some data here*/
});
});
}
我試過郵差 ,它按預期工作。 但是使用create hook,我遇到了錯誤。
可能是什么問題?
您的端點似乎不可用或沒有響應。
你確定這個端點處理內容類型:application / json? 否則嘗試將其作為x-form-www-urlencoded發送。
request.post({
url: MY_URL,
form: {
firstName: empFirstName,
userId: empId
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.