我有一条路线router.route('/cart/:_distributor/order').post(handler)
。当我尝试将来自AngularJS应用程序的请求发送到nodejs服务器时,处理程序函数被调用一次,并在5秒后再次调用。在Chrome / Firefox开发工具中,只有一个请求。在Apache(代理服务器)access_logs中,有两个日志:
[12/Jul/2017:10:08:59 +0200] "POST /cart/5739c9fbc19a8b66c2163ebe/order HTTP/1.1" 200 439
[12/Jul/2017:10:09:04 +0200] "POST /cart/5739c9fbc19a8b66c2163ebe/order HTTP/1.1" 200 1253
在pm2日志中,同样的事情:
POST /cart/5739c9fbc19a8b66c2163ebe/order 200 5001ms
POST /cart/5739c9fbc19a8b66c2163ebe/order 200 30584ms - 568b
客户端应用必须等待大约30秒才能获得此请求的响应。此问题就出现了,对于其他请求,客户端 - 服务器通信正常。
function handler(req, res, next) {
orderModel.createOrder(req.clinic, req.user, req.vc_distributor)
.then(function(data) {
res.json(data);
}, function(err) {
next(err);
});
}