2014-01-06 10 views
0

얘들 아이 URL을 요청하는 데 문제가 있습니다. 괜찮아 보이지만 항상 ECONNRESET 오류가 발생합니다.ECONNRESET 오류 node.js https

나는 루비에 작은 스크립트를 작성 했으므로 잘 동작했다. 터미널에있는 cURL도 작동합니다. https://github.com/joyent/node/issues/5360 https://github.com/joyent/node/issues/5119

어떤 생각이 될 일을 :

나는이 같은 문제 및 스택 오버플로 스레드의 많은 모든 솔루션 ... 시도?

URL이 : https://ecommerce.cielo.com.br/servicos/ecommwsec.do

var https = require('https'); 

var options = { 
host: 'ecommerce.cielo.com.br', 
path: '/servicos/ecommwsec.do', 
//This is what changes the request to a POST request 
method: 'GET', 
}; 

https.globalAgent.options.secureProtocol = 'SSLv3_method'; 

callback = function(response) { 
var str = '' 
response.on('data', function (chunk) { 
str += chunk; 
}); 

response.on('end', function() { 
    console.log(str); 
}); 
} 

var req = https.request(options, callback); 

req.on('error', function(e) { 
    console.log('problem with request: ' + e.message); 
}); 

답변

0

어떻게 지내?

이 솔루션을 사용해 보겠습니다.

var options = { 
    host: 'ecommerce.cielo.com.br', 
    path:'/servicos/ecommwsec.do', 
    method: 'POST', 
    headers: { 
     'Content-Type': 'application/x-www-form-urlencoded', 
     'Content-Length': Buffer.byteLength(body), 
     'user-agent': 'node.js' 
    } 
}; 

    https.globalAgent.options.secureProtocol = 'SSLv3_method'; 

try{ 
    var req = https.request(options, function(res) 
    { 
     res.setEncoding('utf8'); 
     res.on('data', function (chunk) { 
      console.log("body: " + chunk); 
     }).on('end', function(cieloResponse){ 
      console.log(cieloResponse); 
     }); 
     console.log('Response:' + res); 
    }); 

    req.end(); 
}catch(err){ 
    console.log('ERRO: '+ err); 
} 
:

이 옵션을 변경

app.js