Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
36 changes: 23 additions & 13 deletions examples/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,30 @@ registerMasterSignalingClientCallbacks = (signalingClient, formValues, onStatsRe
}
});

// If in WebRTC ingestion mode, retry if no connection was established within 5 seconds.
// If in WebRTC ingestion mode, retry if no connection was established within 30 seconds.
// Note: This is an interim setting - the viewer application will retry after 30 seconds if the connection through the WebRTC Ingestion mode is not successful.
if (master.channelHelper.isIngestionEnabled()) {
setTimeout(function () {
// We check that it's not failed because if the state transitioned to failed,
// the state change callback would handle this already
if (
answerer.getPeerConnection().connectionState !== 'connected' &&
answerer.getPeerConnection().connectionState !== 'failed' &&
answerer.getPeerConnection().connectionState !== 'closed'
) {
console.error(`[${role}] Connection failed to establish within 5 seconds. Retrying...`);
onPeerConnectionFailed(remoteClientId, false, false);
}
}, 5000);
const CHECK_INTERVAL_SECONDS = 5;
const RETRY_TIMEOUT_SECONDS = 30;

for (let i = CHECK_INTERVAL_SECONDS; i <= RETRY_TIMEOUT_SECONDS; i += CHECK_INTERVAL_SECONDS) {
setTimeout(function () {
// check the state each 5 seconds
//enter retry if still connecting after 30 seconds
if (
answerer.getPeerConnection().connectionState !== 'connected' &&
answerer.getPeerConnection().connectionState !== 'failed' &&
answerer.getPeerConnection().connectionState !== 'closed'
) {
if (i < RETRY_TIMEOUT_SECONDS) {
console.log(`[${role}] Still connecting after ${i} seconds.`);
} else {
console.error(`[${role}] Connection was not successful - Will retry after ${RETRY_TIMEOUT_SECONDS} seconds.`);
onPeerConnectionFailed(remoteClientId, false, false);
}
}
}, i * 1000);
}
}
});

Expand Down
Loading