连接ETIMEDOUT Node.js

我在 Auth0 Delegated Administration Extension中使用了创建钩子.

我在触发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*/
            });
        });
}

我尝试过postman,它按预期工作.但是使用create hook,我遇到了错误.

可能是什么问题?

解决方法

您的端点似乎不可用或没有响应.

你确定这个端点处理内容类型:application / json?否则尝试将其作为x-form-www-urlencoded发送.

request.post({
    url: MY_URL,form: {
        firstName: empFirstName,userId: empId
    }

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...