Tôi đã thử the sample from the documentation và nó hoạt động tốt.Yêu cầu Hodeps Node.js Lỗi
Nhưng khi tôi thay đổi URL thành https://api.mercadolibre.com/sites/
, yêu cầu bị treo. Điều duy nhất tôi nhận được là:
{ [Error: socket hang up] code: 'ECONNRESET' }
Dưới đây là mã của tôi:
var https = require('https');
this.dispatch = function(req, res) {
var renderHtml = function(content) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(content, 'utf-8');
}
var parts = req.url.split('/');
var options = {
host: 'api.mercadolibre.com',
port: 443,
path: '/sites/',
method: 'GET'
};
var request = https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
});
request.on('error', function(e) {
console.error('error');
console.error(e);
});
request.end();
return 'item id:' + parts[2];
};
Tôi đã thử với curl, soapUI và với một trình duyệt. Trên tất cả các trường hợp hoạt động rất tốt, nhưng với node.js thì không.
Làm cách nào để có thêm dữ liệu về những gì đang diễn ra?
thêm
Với curl tôi làm: curl --sslv3 https://api.mercadolibre.com/sites/ công trình. Tôi đã thử nghiệm tương tự ở centos 6 và hoạt động quá. Tôi đã cài đặt lại nút, lần này từ nguồn, cùng một vấn đề. Os của tôi là ubuntu 12.04. Cảm ơn.
Bạn sẽ cần hiển thị u bạn đang sử dụng để chúng tôi có thể chẩn đoán vấn đề. – Ashe