Skip to content

Instantly share code, notes, and snippets.

@evanderkoogh
Created December 29, 2015 13:52
Show Gist options
  • Save evanderkoogh/e7e94f036c7a7a6b8f29 to your computer and use it in GitHub Desktop.
Save evanderkoogh/e7e94f036c7a7a6b8f29 to your computer and use it in GitHub Desktop.
Reproduce problem in request/request with regards to maxSocket & timeouts
var request = require('request');
request = request.defaults({agentOptions: {maxSocket: 1}, timeout: 1200});
for(i=0;i < 10;i++) {
console.log("Requesting");
request.get("http://localhost:3000/", function(err, res, body) {
if(err) {
console.log(err);
}
if(body) {
console.log(body);
}
});
}
{
"name": "request_timeout",
"version": "1.0.0",
"description": "",
"main": "client.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.13.3",
"request": "^2.67.0"
}
}
var express = require('express');
var app = express();
app.get('/', function (req, res) {
setTimeout(function() {
res.send("Hello World!");
}, 1000);
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment