【问题标题】:express server unresponsive after 5 POST's在 5 个 POST 后快递服务器无响应
【发布时间】:2015-05-29 22:53:24
【问题描述】:

我正在使用 express 来提供单页 web 应用程序,并作为所述应用程序的 REST 端点。静态页面服务一切正常,但在 5 个帖子后服务器变得无响应。我看过很多其他关于这个问题的帖子,但他们都说只要确保调用 res.send() 或 res.end(),我在某个地方的每次调用中都会这样做,而不管逻辑如何分支。 app.js 代码如下。

/**
 * Module dependencies.
 */

var express = require('express'),
  http = require('http'),
  path = require('path');

var app = express();
var auth = require("./controllers/authentication.js");

http.globalAgent.maxSockets = 100;

app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(app.router);
});

app.configure('development', function(){
  app.use(express.errorHandler());
});

app.get('/', function(req, res) {
        res.sendfile('./public/index.html');
});

app.get('/public/*', function(req, res) {
        res.sendfile('.'+req.url);
});

app.post('/auth/login', function(req, res, next) {
  auth.login(req, res, next);
});

app.post('/auth/logout', function(req, res, next) {
  auth.logout(req, res, next);
});

app.post('/auth/verify', function(req, res, next) {
  auth.verify(req, res, next, function(req, res, next) {
    res.conentType = 'json';
    res.send(200, "authorized");
  });
});

http.createServer(app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});

这是我得到的命令行输出(之后我尝试发出其他请求,但服务器不会处理它们)。我假设我以某种方式没有正确终止连接,但无法弄清楚如何。

【问题讨论】:

    标签: node.js rest express


    【解决方案1】:

    问题与未关闭 mysql 连接池有关

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-09
      • 2018-03-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-27
      • 1970-01-01
      相关资源
      最近更新 更多