Search code examples
javascriptexpressservertimeout

Post request stops working


Im new to expressjs and server-scripting, but I've managed to create a simple server. But when I request to many times in a row, the server just stops responding. What could be the cause of this? Is there some timeout setting?

Server side:

app.post('/test', function (req, res) {
    console.log("Hello, world!");
});

Client side:

$(".post").click(function(){
   var obj = {};
   obj[$(this).attr("id")] = "roo";
   $.post("/test", obj);
});

It stops working after 6 requests. Whats going on?


Solution

  • Try modify code with res.end you might see the difference.

    That's possibly because you didn't response for the HTTP request, it becomes "pending requests". and browsers usually only cached for several requests (exactly 5 for Chrome)

    app.post('/test', function (req, res) {
        console.log("Hello, world!");
        res.end("");
    });