Closed
Description
- Node.js Version: 7.10
- OS: win32
- Scope (install, code, runtime, meta, other?): code
- Module (and version) (if relevant): https
I use https.request to read from server, and the response is fine. But after several minutes, ECONNRESET error crash the application. My question is, besides process.on('uncaughtException') (not recommended by Nodejs), is there a proper way to catch and handle ECONNRESET for https.request?
{ Error: read ECONNRESET at exports._errnoException (util.js:1050:11) at TCP.onread (net.js:582:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
Below is my code.
` var options = {
method: 'GET',
hostname: hostname,
path: url,
auth: username + ':' + password,
ca: [fs.readFileSync(path.resolve(__dirname, '../common/cer.cer'))],
}
const req = https.request(options, function (res) {
res.on('data', (resdata) => {
console.log('data');
});
res.on('end', () => {
console.log('end');
});
})
req.on('error', (e) => {
console.log(e);
});
req.end();
Metadata
Metadata
Assignees
Labels
No labels