Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timeout after 1 minute error on node >=v11.3 in websocket-relay #340

Merged
merged 1 commit into from
Apr 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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+'/');