My internet is slow and unstable ( around 20KBPS during peak hours and may reach 400KBPS at 0100AM ~ 0400AM )...
So I will say that downloading something fail more often than it succeed. ECONNRESET happens almost everytime
All this limitation which brings me to think to use as less internet connection as possible..
My code is usually download and retry 2-3 times if it fails then leave it be and never return which is bad.
I want to know if some request with request library in nodejs may be retried and be successful. Something like 404 and ENOTFOUND definitely won't need a retry while ECONNRESET will definitely need one. I don't really have many clue on this.
So what conditions would prove that retrying may give a successful result ? or perhaps what conditions would prove that retrying will definitely give no result ?
I found more thing to check like EAGAIN which probably mean a website is down but it exist...
You can check the error object in the callback
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (error) {
// retry logic
}
if (!error && response.statusCode == 200) {
console.log(body) // Print the google web page.
}
})