Error: connect ETIMEDOUT, how to deal with this error?

Asked

Viewed 11 times

0

I am mounting a script to download several images that are in an array, but after the script download some images it is interrupted and returns the error:

events.js:377
throw er; // Unhandled 'error' event
^

Error: connect ETIMEDOUT xxx:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: 'xxx',
port: 443
}

My code is this:

let url = imgs[key]

https.get(url, async function(res) {
const fileStream = fs.createWriteStream(`images/0${key}.jpg`)
res.pipe(fileStream)
fileStream.on("finish", function (){
fileStream.close()
})
})

How can I fix this mistake? suggestions of libraries to be used are welcome

  • Hello Marcelo, welcome to the site. It is important [Edit] and add a [mcve] of the problem (DO NOT delete and DO NOT repeat the question), with a step by step of what has already done and explain clearly and objectively and then wait for the reopening process (which will be evaluated by other users). To better enjoy the site, understand and avoid closures is worth reading the Stack Overflow Survival Guide in English. Thank you for understanding.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.