Reputation: 2605
Boys and girls,
i've been messing around with node.js today and I can't seem to reproduce this concurrent magic.
i wrote this rather small server:
var http = require("http");
var server = http.createServer(function(req, res) {
setTimeout(function() {
res.writeHead(200,{"content-type":"text/plain"});
res.end("Hello world!");
}, 10000);
});
server.listen(8000);
but what's strange, when running localhost:8000 in multiple chrome tabs at the same time. its as if the request is 'queued'. 1st tab takes 10 seconds, 2nd tab takes 20 seconds, 3rd tab takes 30 seconds etc...
But when running this very example with Links it behaves how I expect it (concurrently handling requests).
P.S. This seems to occur in Chrome and Firefox
bizarre
Upvotes: 0
Views: 149
Reputation: 42632
The requests for the same URL/hostname get queued client-side in the browser. That has nothing to do with node.js, your code is fine.
If you use different URLs in each tab, you example should work. (for a few tabs)
Also have a look at: Multiple Ajax requests for same URL
Upvotes: 5