简体   繁体   English

Node.js + express + mongodb处理几乎同时触发的两个http get请求

[英]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, 我有一个node.js + express + mongo数据库应用程序,

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. 从客户端,我几乎同时触发了两个http get。 I thought there should be two console.log print out for these two requests. 我认为应该为这两个请求打印两个console.log。 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. 在服务器端,我可以看到两个http get请求到达。 Any idea? 任何想法?

Regards Hammer 关于锤子

More:@CFrei @ Peter 更多:@CFrei @ Peter

I think I know the cause. 我想我知道原因。 I have http://www.google.com in my testString. 我的testString中有http://www.google.com If I remove '//' and '/', then I can see the log printed out. 如果删除“ //”和“ /”,那么我可以看到打印的日志。 I have already used NSUTF8StringEncoding in my native firing of http get. 我已经在HTTP get的本机启动中使用了NSUTF8StringEncoding。 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. 尝试在命令行上使用curl进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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