I've been trying to make a request using node.js with request-promise library and gCloudFunctions located in US to a webpage located in Brazil. When I get access to it, I login with my data.
The problem is that sometimes it works, sometimes it doesn't, when it doesn't I get the following error on my log:
Error: connect ECONNREFUSED xxx.xxx.xx.xxx:xxx
In my local machine the error never occurs, it only happens on gCloud Functions.
What I've done so far:
Retried the requests for more 3 times (on the same initial page), if it didn't work at first attempt, it never worked on the next retries.
Tried to access a different webpage, then the desired one, same as before, sometimes works, sometimes doesn't.
Inserted on my default options requested
rejectUnauthorized: false
. This stabilised the app for about 24h, then the error started occurring again.
My request is set like this:
options = {
rejectUnauthorized: false,
jar: true,
headers: {
"Connection": "keep-alive",
"Host": "xxx.xxx.xxx.br",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
'Cache-Control': 'no-cache',
},
};
I don't know exactly how to generate the error, but when it occurs normally it keeps occurring and after some time the request works, then stops, and so on.
My guesses are about firewall and TSL on google cloud.