Skip to content

Instantly share code, notes, and snippets.

@demian85
Created May 25, 2011 17:10
Show Gist options
  • Save demian85/991389 to your computer and use it in GitHub Desktop.
Save demian85/991389 to your computer and use it in GitHub Desktop.
request timeout test
process.env.TZ = 'UTC';
var util = require('util'),
fs = require('fs'),
request = require('request'),
args = require('argsparser').parse();
for (var count = 0; count < 10; count++) {
(function(i) {
var uri = 'http://www.google.com/?i=' + i;
console.log('Request ' + i);
request({uri : uri}, function(err, response, body) {
if (err) throw err;
console.log('Response ' + i);
}).on('error', function(err) {
throw err;
});
})(count);
}
// execute this script and disconnect the network for 60 seconds, then you connect again and wait for some time, this happens after some time...
/*
Request 0
Request 1
Request 2
Request 3
Request 4
Request 5
Request 6
Request 7
Request 8
Request 9
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: EINVAL, Invalid argument
at Socket._onConnect (net.js:601:18)
at IOWatcher.onWritable [as callback] (net.js:186:12)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment