我在一个看起来像这样的服务器上有一个脚本。
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 套接字的细节。如果有人有任何想法或您需要更多信息,请告诉我。