LINXD-2842-log-protocol-change #36
3
.env
3
.env
@ -7,4 +7,5 @@ SERVER_CERT="./server/ssl/cert.pem"
|
||||
SERVER_KEY="./server/ssl/key.pem"
|
||||
ENABLE_UDP=true
|
||||
ENABLE_TCP=true
|
||||
PREFER_UDP=true
|
||||
PREFER_UDP=true
|
||||
PREFER_TCP=false
|
21
app.js
21
app.js
@ -15,7 +15,8 @@ const mediasoup = require('mediasoup');
|
||||
const isUdpEnabled = process.env.ENABLE_UDP === 'true';
|
||||
const isTcpEnabled = process.env.ENABLE_TCP === 'true';
|
||||
const isUdpPreferred = process.env.PREFER_UDP === 'true';
|
||||
let initialConnection = isUdpPreferred ? 'udp' : 'tcp';
|
||||
const isTcpPreferred = process.env.PREFER_TCP === 'true';
|
||||
let currentConnectionType = isUdpPreferred ? 'udp' : 'tcp';
|
||||
|
||||
let worker;
|
||||
/**
|
||||
@ -562,21 +563,29 @@ const createWebRtcTransportLayer = async (callId, callback) => {
|
||||
enableUdp: isUdpEnabled,
|
||||
enableTcp: isTcpEnabled,
|
||||
preferUdp: isUdpPreferred,
|
||||
preferTcp: isTcpPreferred,
|
||||
iceConsentTimeout: 3
|
||||
};
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-createWebRtcTransport
|
||||
let transport = await videoCalls[callId].router.createWebRtcTransport(webRtcTransport_options);
|
||||
|
||||
sergiu marked this conversation as resolved
Outdated
|
||||
// `iceselectedtuplechange`: Fires when ICE switches transport (e.g., UDP → TCP).
|
||||
transport.on('iceselectedtuplechange', (selectedTuple) => {
|
||||
const { protocol } = selectedTuple;
|
||||
const switchedTo = protocol === 'udp' ? 'tcp' : 'udp';
|
||||
|
||||
if (initialConnection !== protocol) {
|
||||
console.warn(`⚠️ ${protocol.toUpperCase()} blocked! Switching to ${switchedTo.toUpperCase()} for callId: ${callId}`);
|
||||
initialConnection = protocol;
|
||||
if (currentConnectionType !== protocol) {
|
||||
sergiu marked this conversation as resolved
Outdated
cristi
commented
suggestion suggestion `initialConnection` --> `currentConnectionType`
|
||||
console.warn(`⚠️ ${currentConnectionType.toUpperCase()} blocked! Switching to ${protocol.toUpperCase()} for callId: ${callId}`);
|
||||
currentConnectionType = protocol;
|
||||
}
|
||||
});
|
||||
|
||||
// `icestatechange`: Fires when ICE connection state changes (e.g., new, connected, failed).
|
||||
transport.on('icestatechange', (iceState) => {
|
||||
console.log(`[ICE STATE CHANGE] callId: ${callId} | State: ${iceState}`);
|
||||
if (iceState === 'failed' || iceState === 'disconnected') {
|
||||
console.warn(`⚠️ ICE failure detected for callId: ${callId}! Possible UDP blockage.`);
|
||||
}
|
||||
});
|
||||
|
||||
// Handler for when DTLS(Datagram Transport Layer Security) changes
|
||||
transport.on('dtlsstatechange', (dtlsState) => {
|
||||
|
1150
package-lock.json
generated
1150
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
||||
"@types/express": "^4.17.13",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.1",
|
||||
"mediasoup": "^3.10.4",
|
||||
"mediasoup": "^3.15.5",
|
||||
"mediasoup-client": "^3.6.54",
|
||||
"parcel": "^2.7.0",
|
||||
"socket.io": "^2.0.3",
|
||||
|
Loading…
x
Reference in New Issue
Block a user
This seems redundant. Suggestion: we could remove it altogether.