Created
December 29, 2015 13:52
-
-
Save evanderkoogh/e7e94f036c7a7a6b8f29 to your computer and use it in GitHub Desktop.
Reproduce problem in request/request with regards to maxSocket & timeouts
This file contains hidden or 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
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); | |
} | |
}); | |
} |
This file contains hidden or 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
{ | |
"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" | |
} | |
} |
This file contains hidden or 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
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