osx - Socket.io: How to handle closing connections? -
i'm trying understand "physical" limits of application.
on client side:
var socket = io.connect("http://127.0.0.1:6701"); socket.on('connect', function() { socket.disconnect(); }); socket.on('disconnect', function() { socket.socket.reconnect(); }); on server side:
var io = require('socket.io').listen(6701); io.sockets.on('connection', function(socket) { socket.on('disconnect', function(reason) { var o = object.keys(socket.manager.open).length , c = object.keys(socket.manager.closed).length , ca = object.keys(socket.manager.closeda).length , h = object.keys(socket.manager.handshaken).length console.log("open: " + o) console.log("closed: " + c) console.log("handshaken: " + h) console.log("closeda: " + ca) console.log("---"); }); }); when in osx hit file limit (256) statistics following
open: 471 closed: 235 handshaken: 471 closeda: 235 what puzzling me is:
- if forcefully close connection (this client
disconnect(), why i'm still using file handle (so hit file limit) edit: adding delay seems server can keep breath , never reaches file limit)? - is there way close socket pretty sure file limit reached (i know can push 65k)?
- is there way know i'm reaching file limit, can stop accepting connection?
thank you
it's better if client sends "terminate" command server closes connection, other way around.
server wait until timeout before giving on connection. if timeout small, loads of connections coming in, overload it. that's why, example, disable keep-alive on app servers.
delay helps because server has time close connection before opening new one.
Comments
Post a Comment