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
|
33
README.md
33
README.md
@ -9,17 +9,22 @@
|
||||
### Development
|
||||
|
||||
##### To start in development mode you must:
|
||||
|
||||
1. Install the dependencies `npm install`.
|
||||
|
||||
2. Go to the linx-devops project and run the `create_certificate_for_domain.sh` script from `private-system-trusted-cert`, it expects an ip/domain as the first argument.
|
||||
ex: `sh create_certificate_for_domain.sh 192.168.1.199`
|
||||
(Use your private IP-address)
|
||||
2. Go to the `linx-devops/scaling-tools/private-system-truste-cert` project and generate a new server certificate and key:
|
||||
|
||||
sh create_certificate_for_domain.sh 192.168.1.110 #local IP
|
||||
# generates files
|
||||
nginx-selfsigned.crt
|
||||
device.key
|
||||
|
||||
3. You need to update the Video Server in the provisioning to point to your private IP. ex: https://192.168.1.199:3000
|
||||
|
||||
4. The generated files must be moved to server/ssl and renamed as follows:
|
||||
- device.key -> key.pem
|
||||
- nginx-selfsigned.crt -> cert.pem
|
||||
|
||||
cp device.key {mediasoup_project}/server/ssl/key.pem
|
||||
cp nginx-selfsigned.crt {mediosup_project}/server/ssl/cert.pem
|
||||
|
||||
5. Go to https://dev.linx.safemobile.com/dispatcher/resources/help/LINXHelp.html#safemobile-certificate-import and import the certificate for your system type
|
||||
|
||||
@ -33,22 +38,22 @@
|
||||
##### To start in production mode you must:
|
||||
1. Install the dependencies `npm install`.
|
||||
2. Run the `npm start:prod` command to start the server in production mode.
|
||||
(To connect to the terminal, use `pm2 log video-server`)
|
||||
(To connect to the terminal, use `pm2 log video-server`)
|
||||
|
||||
|
||||
### Web client
|
||||
|
||||
- The server will start by default on port 3000, and the ssl certificates will have to be configured
|
||||
- The web client can be accessed using the /sfu path
|
||||
ex: https://HOST/sfu/?assetId=1&&accountId=1&producer=true&dest_asset_id=75&assetName=Adi
|
||||
assetId = asset id of the unit on which you are doing the test
|
||||
accountId = account id of the unit on which you are doing the test
|
||||
producer = it will always be true because you are the producer
|
||||
(it's possible to put false, but then you have to have another client with producer true)
|
||||
assetName = asset name of the unit on which you are doing the test
|
||||
dest_asset_id= the addressee with whom the call is made
|
||||
ex: https://HOST/sfu/?assetId=1&&accountId=1&producer=true&dest_asset_id=75&assetName=Adi
|
||||
assetId = asset id of the unit on which you are doing the test
|
||||
accountId = account id of the unit on which you are doing the test
|
||||
producer = it will always be true because you are the producer
|
||||
(it's possible to put false, but then you have to have another client with producer true)
|
||||
assetName = asset name of the unit on which you are doing the test
|
||||
dest_asset_id= the addressee with whom the call is made
|
||||
- To make a call using this client, you need a microphone and permission to use it
|
||||
- For any changes related to the client, the command `npm run watch' will have to be used to generate the bundle.js used by the web client
|
||||
|
||||
### Demo project
|
||||
The demo project used initially and then modified for our needs `https://github.com/jamalag/mediasoup2`
|
||||
The demo project used initially and then modified for our needs `https://github.com/jamalag/mediasoup2`
|
30
app.js
30
app.js
@ -12,6 +12,11 @@ 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';
|
||||
const isTcpPreferred = process.env.PREFER_TCP === 'true';
|
||||
let currentConnectionType = isUdpPreferred ? 'udp' : 'tcp';
|
||||
|
||||
let worker;
|
||||
/**
|
||||
@ -555,14 +560,33 @@ 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,
|
||||
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;
|
||||
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) => {
|
||||
console.log(`transport | dtlsstatechange | calldId ${callId} | dtlsState ${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.