I have a localhost node.js web server that contains 1MB of data
And a client which I'm trying to download the data from using require('http')
after 130 iterations the program breaks:
Error: connect ECONNREFUSED 127.0.0.1:3000
Here is my code:
const timeWrapper = (callback, param) => {
const start = performance.now();
callback(param)
const stop = performance.now();
console.log('Runtime: ', (stop - start)/1000 + ' seconds');
}
const getData = (from) => {
for (let i = 0; i < 1000; i++) {
download(from);
}
}
// Don't work
timeWrapper(getData, web);
I'd like to know how to fix it