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"
|
SERVER_KEY="./server/ssl/key.pem"
|
||||||
ENABLE_UDP=true
|
ENABLE_UDP=true
|
||||||
ENABLE_TCP=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 isUdpEnabled = process.env.ENABLE_UDP === 'true';
|
||||||
const isTcpEnabled = process.env.ENABLE_TCP === 'true';
|
const isTcpEnabled = process.env.ENABLE_TCP === 'true';
|
||||||
const isUdpPreferred = process.env.PREFER_UDP === '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;
|
let worker;
|
||||||
/**
|
/**
|
||||||
@ -562,21 +563,29 @@ const createWebRtcTransportLayer = async (callId, callback) => {
|
|||||||
enableUdp: isUdpEnabled,
|
enableUdp: isUdpEnabled,
|
||||||
enableTcp: isTcpEnabled,
|
enableTcp: isTcpEnabled,
|
||||||
preferUdp: isUdpPreferred,
|
preferUdp: isUdpPreferred,
|
||||||
|
preferTcp: isTcpPreferred,
|
||||||
|
iceConsentTimeout: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-createWebRtcTransport
|
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-createWebRtcTransport
|
||||||
let transport = await videoCalls[callId].router.createWebRtcTransport(webRtcTransport_options);
|
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) => {
|
transport.on('iceselectedtuplechange', (selectedTuple) => {
|
||||||
const { protocol } = selectedTuple;
|
const { protocol } = selectedTuple;
|
||||||
const switchedTo = protocol === 'udp' ? 'tcp' : 'udp';
|
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}`);
|
||||||
if (initialConnection !== protocol) {
|
currentConnectionType = protocol;
|
||||||
console.warn(`⚠️ ${protocol.toUpperCase()} blocked! Switching to ${switchedTo.toUpperCase()} for callId: ${callId}`);
|
|
||||||
initialConnection = 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
|
// Handler for when DTLS(Datagram Transport Layer Security) changes
|
||||||
transport.on('dtlsstatechange', (dtlsState) => {
|
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",
|
"@types/express": "^4.17.13",
|
||||||
"dotenv": "^16.0.1",
|
"dotenv": "^16.0.1",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"mediasoup": "^3.10.4",
|
"mediasoup": "^3.15.5",
|
||||||
"mediasoup-client": "^3.6.54",
|
"mediasoup-client": "^3.6.54",
|
||||||
"parcel": "^2.7.0",
|
"parcel": "^2.7.0",
|
||||||
"socket.io": "^2.0.3",
|
"socket.io": "^2.0.3",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user
This seems redundant. Suggestion: we could remove it altogether.