简体   繁体   中英

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?

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("");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM