0

I have 2 systems using Nodejs 16.19.0 - one on my local Windows 11 and another in a GKE pod running a Ubuntu 20 container. In both systems, I open an interactive Nodejs prompt and run the following, pointing to some IP address that I know will NOT reply and cause a timeout on the client side:

$ node # open interactive nodejs prompt and run the following at once:

console.log(new Date());
req=http.request('http://x.x.x.x');
req.on('error', ()=>{}); // just to cleanup the output
req.on('close', () => { console.log('close ' + new Date()); });

I print the start and end dates to see how long it takes the client to close with the timeout.

In my local system, it takes ~20 seconds. In the other system, it takes 130 seconds. I didn't configure anything special in my Node. Why is there a difference?

Also, the consequence of this, is that when I also add a "timeout" handler for, say, 30 seconds, it will NOT fire on Windows and WILL fire in the pod...

Sagi Mann
  • 2,967
  • 6
  • 39
  • 72
  • It could be possible due to network latency to answer your question we might need more information. Is it always taking more time on GKE prod? Try to run the network trace on both and see if there are any differences. It is possible there are some more filtering on your prod system that makes the request taking more time. – Apoorva Chikara Jan 10 '23 at 09:59
  • found a similar question with the right explanation: https://stackoverflow.com/questions/3586760/how-do-i-set-a-timeout-for-client-http-connections-in-node-js – Sagi Mann Jan 10 '23 at 15:36
  • I think the question you tagged is to set timeout for HTTP request, however you are asking the time taken for HTTP request on dofferent system are different, is it correct? – Apoorva Chikara Jan 11 '23 at 03:15
  • that question's answer explains the diff between Win and Linux, like in my case – Sagi Mann Jan 11 '23 at 06:45

0 Answers0