Link to home
Start Free TrialLog in
Avatar of kevbob650
kevbob650Flag for United States of America

asked on

NodeJS Timing Out

I have a node js server using express and socket.io.  I found a function I would love to try but not sure how to write the code. The code below is written using http.createServer, but since I'm using express, it's not the same format and I don't know how to write this???

How I create the server....
var express = require('/usr/lib/node_modules/express');
var app = express();
var server = require('http').Server(app);

The functionality I would like to duplicate....
http.createServer(function (req, res) {
     res.socket.setTimeout(10);
     res.socket.removeAllListeners('timeout');
     res.socket.once('timeout', function () {
     res.writeHead(200, {'Content-Type': 'text/plain'});
     res.end('Hello World\n');
  });
}).listen(8888);

Any help would be appreciated!
ASKER CERTIFIED SOLUTION
Avatar of Neeraj Soni
Neeraj Soni
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial