Skip to content

Commit

Permalink
Fix timeout after 1 minute error on node >=v11.3 in websocket-relay
Browse files Browse the repository at this point in the history
  • Loading branch information
alphacornutum committed Apr 26, 2020
1 parent 9cf21d3 commit 51fcdd4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions websocket-relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down Expand Up @@ -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
);
Expand All @@ -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+'/<secret>');
console.log('Awaiting WebSocket connections on ws://127.0.0.1:'+WEBSOCKET_PORT+'/');

0 comments on commit 51fcdd4

Please sign in to comment.