javascript - Node - Request.js ECONNRESET 错误仅在服务器上

标签 javascript node.js request

我的服务器上有一个如下所示的脚本。

request = require('request');
require('longjohn');
request.post(
    { 
        url : 'https://example.com/api/thing/',
        form : {
            api_key : "blahblah",
            thing_id : 0
        },
        json : true
    },
    function(error, response, body){
        console.log(error, response);
    }
);

当我在本地运行它时,它工作得很好,但是当我在服务器上运行它时,我得到了这个。

{ [Error: read ECONNRESET]
code: 'ECONNRESET',
errno: 'ECONNRESET',
syscall: 'read',
__cached_trace__: 
[ { receiver: [Object],
   fun: [Function: errnoException],
   pos: 22969 },
 { receiver: [Object], fun: [Function: onread], pos: 14584 },
 {},
 { receiver: [Object], fun: [Function], pos: 19529 },
 { receiver: [Object], fun: [Function], pos: 49346 },
 { receiver: [Object],
   fun: [Function: _tickCallback],
   pos: 14030 },
 { receiver: [Object], fun: [Function], pos: 14031 },
 { receiver: [Object], fun: [Object], pos: 4502 },
 { receiver: [Object], fun: [Function], pos: 28039 },
 {},
 { receiver: [Object], fun: [Function], pos: 48679 },
 { receiver: [Object], fun: [Function], pos: 36057 },
 { receiver: [Object], fun: [Object], pos: 40546 },
 { receiver: [Object], fun: [Function], pos: 3570 },
 { receiver: [Object], fun: [Function], pos: 17260 },
 { receiver: [Object], fun: [Function], pos: 36440 },
 { receiver: [Object], fun: [Function], pos: 11960 },
 {},
 { receiver: [Object], fun: [Function], pos: 11634 },
 { receiver: [Object], fun: [Object], pos: 2292 },
 { receiver: [Object], fun: [Object], pos: 1738 },
 { receiver: [Object], fun: [Function], pos: 3238 },
 { receiver: {}, fun: [Function], pos: 121 },
 { receiver: [Object], fun: [Function], pos: 12854 },
 { receiver: [Object], fun: [Function], pos: 13365 },
 { receiver: [Object], fun: [Function], pos: 10114 } ],
 __previous__: 
 { [Error]
 id: 73,
 location: 'Readable.on (_stream_readable.js:679)',
 __location__: 'EventEmitter.on',
 __previous__: 
  { [Error]
    id: 60,
    location: 'ClientRequest.onSocket (http.js:1700)',
    __location__: 'process.nextTick',
    __previous__: [Object],
    __trace_count__: 2,
    __cached_trace__: [Object] },
 __trace_count__: 3,
 __cached_trace__: 
  [ [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    {},
    [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    {},
    [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    [Object],
    [Object] ] } }

我不熟悉tcp套接字的细节。如果有人有任何想法或需要更多信息,请告诉我。

最佳答案

我们的机架空间管理支持团队最终解决了这个问题 - 这是一个硬件配置问题。

It looks like your problem is some where between the firewall and the load balancer.

It appears this issue is being caused by the DNS doctoring from the firewall.

If I set in the /etc/hosts file on xxx-node-prod-1 that the ip address for production.xxx.com is xxx.xxx.xxx.xxx, everything works perfectly.

The problem appears when the curl command is hitting the private natted ip of the load balancer.

我们使用硬件 FW 和 LB 进行此设置,但他们这边的某些东西很奇怪。

关于javascript - Node - Request.js ECONNRESET 错误仅在服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18647535/

相关文章:

javascript - 将 gettime 保存到表单字段

apache - node.js node-http-proxy 不传递 Node 模块

node.js - 防止在不需要授权时在 Redis 中创建 session

iphone - 请求苹果在iOS中使用功能?

python - 使用请求库用python模拟ajax请求

javascript - 无法通过无法读取 null 的属性样式

javascript - 我应该选择哪个 Google map 选项?

javascript - data-* 每个类的值

javascript - Commander-js 的强制参数

返回空响应对 HEAD 请求的 SEO 影响