Socket.io 1.0: customize the close timeout
How do I configure the "close timeout" option using the code below?
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
...
server.listen(port, ip);
I read the doc about socket.io and I found that:
var socket = require('socket.io')({
// options go here
});
but I cannot add parameters because I am using a variable server
.
Thank.
+3
source to share
2 answers
Have you seen this one ?
var io = require('socket.io').listen(80);
io.set('close timeout', 60);
io.set('heartbeat timeout', 60);
Maybe something like
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
io.set('close timeout', 60);
server.listen(port, ip);
Edit: This is a long shot, but:
var app = require('express')();
var server = require('http').Server(app);
server['close timeout'] = 60;
var io = require('socket.io')(server);
server.listen(port, ip);
Edit: Found this on socket.io docs :
// pass a server and the `serveClient` option
var io = require('socket.io')(http, { serveClient: false });
So how about this?
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server, { 'close timeout': 60});
server.listen(port, ip);
One more Edit: In the docs :
The same parameters passed to socket.io are always passed. The engine.io server is created. See engine.io options for reference.
pingTimeout (Number): how many ms without a pong packet to consider the connection closed (60000)
Can you try this?
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server, { pingTimeout: 60000});
server.listen(port, ip);
+2
source to share