LINXD-2842-log-protocol-change #36
21
app.js
21
app.js
@ -12,6 +12,10 @@ try {
|
||||
console.log('https support is disabled!');
|
||||
}
|
||||
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';
|
||||
|
||||
let worker;
|
||||
/**
|
||||
@ -555,14 +559,25 @@ const createWebRtcTransportLayer = async (callId, callback) => {
|
||||
announcedIp: process.env.ANNOUNCED_IP, // Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with private IP).
|
||||
},
|
||||
],
|
||||
enableUdp: process.env.ENABLE_UDP === 'true',
|
||||
enableTcp: process.env.ENABLE_TCP === 'true',
|
||||
preferUdp: process.env.PREFER_UDP === 'true',
|
||||
enableUdp: isUdpEnabled,
|
||||
enableTcp: isTcpEnabled,
|
||||
preferUdp: isUdpPreferred,
|
||||
};
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-createWebRtcTransport
|
||||
let transport = await videoCalls[callId].router.createWebRtcTransport(webRtcTransport_options);
|
||||
|
||||
transport.on('iceselectedtuplechange', (selectedTuple) => {
|
||||
const { protocol } = selectedTuple;
|
||||
const switchedTo = protocol === 'udp' ? 'tcp' : 'udp';
|
||||
sergiu marked this conversation as resolved
Outdated
|
||||
|
||||
if (initialConnection !== protocol) {
|
||||
console.warn(`⚠️ ${protocol.toUpperCase()} blocked! Switching to ${switchedTo.toUpperCase()} for callId: ${callId}`);
|
||||
initialConnection = protocol;
|
||||
sergiu marked this conversation as resolved
Outdated
cristi
commented
suggestion suggestion `initialConnection` --> `currentConnectionType`
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Handler for when DTLS(Datagram Transport Layer Security) changes
|
||||
transport.on('dtlsstatechange', (dtlsState) => {
|
||||
console.log(`transport | dtlsstatechange | calldId ${callId} | dtlsState ${dtlsState}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user
This seems redundant. Suggestion: we could remove it altogether.