简体   繁体   中英

Node.js+express+mongodb handling two http get requests fired almost at the same time

I have a node.js+express+mongo DB app where,

app.get('/test/:testString', function (req, res) {
     console.log('req.params.testString: %s ', req.params.testString);
     ... insert to a collection....

from my client side, I fired two http get almost at the same time. I thought there should be two console.log print out for these two requests. However, strangely, only the second request's log shows and only the second request goes thru the collection insertion. On my server side terminal, I can see two http get requests arrived. Any idea?

Regards Hammer

More:@CFrei @ Peter

I think I know the cause. I have http://www.google.com in my testString. If I remove '//' and '/', then I can see the log printed out. I have already used NSUTF8StringEncoding in my native firing of http get. Any special handling need to be added on express side?

If the client is a browser my first guess would be browser connection management interfering. Try using curl on the command line instead to test.

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