diff --git a/websocket-relay.js b/websocket-relay.js index 1cb47f15..0b9ab57a 100755 --- a/websocket-relay.js +++ b/websocket-relay.js @@ -27,7 +27,7 @@ socketServer.connectionCount = 0; socketServer.on('connection', function(socket, upgradeReq) { socketServer.connectionCount++; console.log( - 'New WebSocket Connection: ', + 'New WebSocket Connection: ', (upgradeReq || socket.upgradeReq).socket.remoteAddress, (upgradeReq || socket.upgradeReq).headers['user-agent'], '('+socketServer.connectionCount+' total)' @@ -61,7 +61,7 @@ var streamServer = http.createServer( function(request, response) { response.connection.setTimeout(0); console.log( - 'Stream Connected: ' + + 'Stream Connected: ' + request.socket.remoteAddress + ':' + request.socket.remotePort ); @@ -83,7 +83,10 @@ var streamServer = http.createServer( function(request, response) { var path = 'recordings/' + Date.now() + '.ts'; request.socket.recording = fs.createWriteStream(path); } -}).listen(STREAM_PORT); +}) +// Keep the socket open for streaming +streamServer.headersTimeout = 0; +streamServer.listen(STREAM_PORT); console.log('Listening for incomming MPEG-TS Stream on http://127.0.0.1:'+STREAM_PORT+'/'); console.log('Awaiting WebSocket connections on ws://127.0.0.1:'+WEBSOCKET_PORT+'/');