title: nodejs express set server: possible EventEmitter memory leak detected
body: <p><img src="https://i.stack.imgur.com/ASiIS.png" alt="code"></p>
  
  <p>My node js like that but when i start this server, it meet te error :</p>
  
  <p><img src="https://i.stack.imgur.com/4spa5.png" alt="error"></p>
  
  <p>and my node version is v0.6.18.
  and i follow the suggestion as 
  <a href="https://stackoverflow.com/questions/9768444/possible-eventemitter-memory-leak-detected">possible EventEmitter memory leak detected</a></p>
  
  <p>add req.setMaxListeners(0)
  but it doesn't work.</p>
  
  <p>i attach my whole code here :</p>
  
  <pre><code>        var express = require('../node_modules/express'),
          redis = require('../node_modules/socket.io/node_modules/redis'), 
          // io = require('../node_modules/socket.io').listen(app),
          fs = require('fs');
  
      var app = express.createServer();
      app.use(express.bodyParser());
  
      var cache = redis.createClient(7010, "192.168.100.18");
  
      var port = 8888;
  
      // get html page ok
      app.get('/*', function (req, res) {
          req.setMaxListeners(0);
          res.sendfile(__dirname + '/html/' + req.params[0]);
      });
  
      // get js page ok
      app.get('/js/*', function (req, res){
          res.sendfile(__dirname + '/html/js/' + req.params[0]);
      });
  
      // get image ok
      app.get('/img/*', function (req, res){
          res.sendfile(__dirname + '/html/img/' + req.params[0]);
      });
  
      // login interface ok
      app.post('/login*', function(req, res, next){
          console.log("access login")
          var username = req.body.username;
          var password = req.body.password;
  
          if(username == null || password == null){
              console.log("username or password is nil")
              res.json({ret:false})
              return
          }
  
          cache.hget("margin:user:password", username, function(err, resp){
              if (err != null){
                  console.log(err)
              }
              if(resp == null){
                  res.json({ret:false})
                  return
              }
              res.json({ret:true})
              return
          })
      });
  
      // upload file interface ok
      app.post('/upload*', function(req, res, next){
          console.log(req.files)
          console.log(req.body)
          fs.readFile(req.files.image.path, function(err, data){
              var unix = Math.round(+new Date()/1000);
              var imagename = unix + "." + req.files.image.type.split("/")[1]
              var newPath = __dirname + "/html/img/" + imagename;
              fs.writeFile(newPath, data, function(err){
                  if(err == null){
                      res.json({ret:true, img:"http://192.168.100.188:" + port + "/html/img/" + imagename});
                      return;
                  }
                  res.json({ret:false});
              });
          });
      });
  
      app.listen(port);
  </code></pre>
  
  <p>my request url like localhost:8888/index.html</p>
  
  <p>thanks a lot.</p>
  
  <p>add error:</p>
  
  <pre><code>    (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
  Trace: 
      at Socket.&lt;anonymous&gt; (events.js:139:15)
      at ServerResponse.sendfile (/data/www/margintop/server/node_modules/express/lib/response.js:185:14)
      at /data/www/margintop/server/webserver/webserver.js:17:9
      at callbacks (/data/www/margintop/server/node_modules/express/lib/router/index.js:165:11)
      at param (/data/www/margintop/server/node_modules/express/lib/router/index.js:139:11)
      at pass (/data/www/margintop/server/node_modules/express/lib/router/index.js:146:5)
      at Router._dispatch (/data/www/margintop/server/node_modules/express/lib/router/index.js:173:4)
      at Object.router [as handle] (/data/www/margintop/server/node_modules/express/lib/router/index.js:33:10)
      at next (/data/www/margintop/server/node_modules/express/node_modules/connect/lib/proto.js:190:15)
      at multipart (/data/www/margintop/server/node_modules/express/node_modules/connect/lib/middleware/multipart.js:52:61)
  </code></pre>