socket.destroy(); }); socket.setTimeout(this.timeout, function () { logger.warn('connection is timeout without communication, the remote ip is %s && port is %s', socket.remoteAddress, socket.remotePort);
stream.setTimeout(timeout, function () { client.destroy(); client.emit('close');
this.client.setTimeout(this._connectTimeout * 1000, () => { this.client.setTimeout(0);
async function checkPortListening(port) { const listening = new Promise(resolve => { const client = Net.createConnection({ port }); client.setTimeout(100); client.on("error", () => resolve(false)); client.on("connect", () => { client.end(); resolve(true); }); }); return listening; }
/** * * @private */ _onConnect() { this._socket.setTimeout(0); if (this._keepAlive || this._keepAlive === 0) this._socket.setKeepAlive(true, this._keepAlive); else this._socket.setKeepAlive(false); this.emitSafe('connect'); }
//Set connection timeout to prevent long running queries failing on large databases - mostly capacode refresh on MySQL server.on('connection', function(connection) { connection.setTimeout(600 * 1000); });
//ffmpeg pushed stream in here to make a pipe app.all(['/streamIn/:ke/:id','/streamIn/:ke/:id/:feed'], function (req, res) { var checkOrigin = function(search){return req.headers.host.indexOf(search)>-1} if(checkOrigin('127.0.0.1')){ if(!req.params.feed){req.params.feed='1'} if(!s.group[req.params.ke].mon[req.params.id].streamIn[req.params.feed]){ s.group[req.params.ke].mon[req.params.id].streamIn[req.params.feed] = new events.EventEmitter().setMaxListeners(0) } //req.params.feed = Feed Number res.connection.setTimeout(0); req.on('data', function(buffer){ s.group[req.params.ke].mon[req.params.id].streamIn[req.params.feed].emit('data',buffer) }); req.on('end',function(){ // console.log('streamIn closed',req.params); }); }else{ res.end('Local connection is only allowed.') } })
_start() { this.socket = Net.createConnection(this.info.port, this.info.hostname, () => { //rtmp handshark c0c1 let c0c1 = Crypto.randomBytes(1537); c0c1.writeUInt8(3); c0c1.writeUInt32BE(Date.now() / 1000, 1); c0c1.writeUInt32BE(0, 5); this.socket.write(c0c1); // Logger.debug('[rtmp client] write c0c1'); }); this.socket.on('data', this.onSocketData.bind(this)); this.socket.on('error', this.onSocketError.bind(this)); this.socket.on('close', this.onSocketClose.bind(this)); this.socket.on('timeout', this.onSocketTimeout.bind(this)); this.socket.setTimeout(60000); }
require('http').createServer( function(request, response) { var params = request.url.substr(1).split('/'); if( params[0] == STREAM_SECRET ) { response.connection.setTimeout(0); width = (params[1] || 320)|0; height = (params[2] || 240)|0; console.log( 'Stream Connected: ' + request.socket.remoteAddress + ':' + request.socket.remotePort + ' size: ' + width + 'x' + height ); request.on('data', function(data){ socketServer.broadcast(data, {binary:true}); }); } else { console.log( 'Failed Stream Connection: '+ request.socket.remoteAddress + request.socket.remotePort + ' - wrong secret.' ); response.end(); } }).listen(STREAM_PORT)
start() { net.createServer((socket) => { socket.setEncoding('utf8'); socket.on('error', (err) => { socket.end(); socket.destroy(); }); socket.write('Hi There ' + socket.remoteAddress + ':' + socket.remotePort + '\r\n'); socket.setTimeout(5000); socket.on('timeout', () => { this.log(socket); socket.end(); socket.destroy(); }); socket.on('data', (data) => { this.log(socket, data); socket.end(); socket.destroy(); }); }).on('error', (err) => { this.onError(err); }).listen(this.port); }
socket.on('timeout', err => { socket.destroy(); }); socket.setTimeout(this.socketTimeout); this.socketList.push(socket);
req.connection.setTimeout( 1000 * 60 * 10 ); // ten minutes
_connect() { this._socket = net.connect(Number(this.address.port), this.address.hostname); this._socket.setNoDelay(this.options.noDelay); this._socket.setTimeout(this.options.connectTimeout, () => { const err = new Error('socket#' + this.url + ' connect timeout(' + this.options.connectTimeout + 'ms)'); err.name = 'RpcSocketConnectTimeoutError'; this._socket.once('connect', () => { this._connected = true; this._socket.setTimeout(0); this._clientUrl = this._socket.localAddress + ':' + this._socket.localPort; this.ready(true);
socket.setTimeout(self.options.masterConnectionTimeout); socket.on('timeout', function() { self.logger.error("Received a timeout on the long-running Master connection! Will try to re-register the framework scheduler!"); socket.destroy(); socket.setTimeout(0); if (httpRequest !== self.httpRequest) { self.logger.info("Already reconnected, not attempting again."); socket.setTimeout(self.options.masterConnectionTimeout); socket.on('timeout', function() { self.logger.error("Couldn't receive a response for the redirect request from the last leading master!");
ghostSocket.setTimeout(options.socketTimeoutInMS); ghostSocket.on('timeout', (() => { if (delayOnConnectTimeout) { })); delayOnConnectTimeout = setTimeout(() => { ghostSocket.destroy(); if (err.retry && tries < options.maxTries) { tries = tries + 1; setTimeout(retry, options.retryTimeoutInMS); return;