Created
May 25, 2011 17:10
-
-
Save demian85/991389 to your computer and use it in GitHub Desktop.
request timeout test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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