Coturn port conf

pull/656/head
gtunon 2021-10-01 09:09:04 +02:00
parent 2e5f605225
commit 57faf14b21
10 changed files with 36 additions and 13 deletions

View File

@ -1526,8 +1526,8 @@ export class Session extends EventDispatcher {
private processJoinRoomResponse(opts: LocalConnectionOptions) { private processJoinRoomResponse(opts: LocalConnectionOptions) {
this.sessionId = opts.session; this.sessionId = opts.session;
if (opts.coturnIp != null && opts.turnUsername != null && opts.turnCredential != null) { if (opts.coturnIp != null && opts.coturnPort != null && opts.turnUsername != null && opts.turnCredential != null) {
const turnUrl1 = 'turn:' + opts.coturnIp + ':3478'; const turnUrl1 = 'turn:' + opts.coturnIp + ':' + opts.coturnPort;
this.openvidu.iceServers = [ this.openvidu.iceServers = [
{ urls: [turnUrl1], username: opts.turnUsername, credential: opts.turnCredential } { urls: [turnUrl1], username: opts.turnUsername, credential: opts.turnCredential }
]; ];

View File

@ -28,6 +28,7 @@ export interface LocalConnectionOptions {
role: string; role: string;
record: boolean; record: boolean;
coturnIp: string; coturnIp: string;
coturnPort: string;
turnUsername: string; turnUsername: string;
turnCredential: string; turnCredential: string;
version: string; version: string;

View File

@ -162,6 +162,7 @@ public class ProtocolElements {
public static final String PARTICIPANTJOINED_RECORD_PARAM = "record"; public static final String PARTICIPANTJOINED_RECORD_PARAM = "record";
public static final String PARTICIPANTJOINED_ROLE_PARAM = "role"; public static final String PARTICIPANTJOINED_ROLE_PARAM = "role";
public static final String PARTICIPANTJOINED_COTURNIP_PARAM = "coturnIp"; public static final String PARTICIPANTJOINED_COTURNIP_PARAM = "coturnIp";
public static final String PARTICIPANTJOINED_COTURNPORT_PARAM = "coturnPort";
public static final String PARTICIPANTJOINED_TURNUSERNAME_PARAM = "turnUsername"; public static final String PARTICIPANTJOINED_TURNUSERNAME_PARAM = "turnUsername";
public static final String PARTICIPANTJOINED_TURNCREDENTIAL_PARAM = "turnCredential"; public static final String PARTICIPANTJOINED_TURNCREDENTIAL_PARAM = "turnCredential";

View File

@ -40,6 +40,7 @@ services:
- COTURN_REDIS_IP=127.0.0.1 - COTURN_REDIS_IP=127.0.0.1
- COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET} - COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET}
- COTURN_IP=${COTURN_IP:-auto-ipv4} - COTURN_IP=${COTURN_IP:-auto-ipv4}
- COTURN_PORT=${COTURN_PORT:-3478}
logging: logging:
options: options:
max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}" max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"
@ -84,11 +85,11 @@ services:
- DB_PASSWORD=${OPENVIDU_SECRET} - DB_PASSWORD=${OPENVIDU_SECRET}
command: command:
- --log-file=stdout - --log-file=stdout
- --listening-port=3478 - --listening-port=${COTURN_PORT:-3478}
- --fingerprint - --fingerprint
- --lt-cred-mech - --lt-cred-mech
- --min-port=57001 - --min-port=${COTURN_MIN_PORT:-57001}
- --max-port=65535 - --max-port=${COTURN_MIN_PORT:-65535}
- --realm=openvidu - --realm=openvidu
- --verbose - --verbose
logging: logging:

View File

@ -45,6 +45,7 @@ services:
- COTURN_REDIS_IP=127.0.0.1 - COTURN_REDIS_IP=127.0.0.1
- COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET} - COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET}
- COTURN_IP=${COTURN_IP:-auto-ipv4} - COTURN_IP=${COTURN_IP:-auto-ipv4}
- COTURN_PORT=${COTURN_PORT:-3478}
- OPENVIDU_PRO_CLUSTER=true - OPENVIDU_PRO_CLUSTER=true
- OPENVIDU_PRO_KIBANA_HOST=${OPENVIDU_PRO_KIBANA_HOST:-http://127.0.0.1/kibana} - OPENVIDU_PRO_KIBANA_HOST=${OPENVIDU_PRO_KIBANA_HOST:-http://127.0.0.1/kibana}
- OPENVIDU_PRO_ELASTICSEARCH_HOST=${OPENVIDU_PRO_ELASTICSEARCH_HOST:-http://127.0.0.1:9200} - OPENVIDU_PRO_ELASTICSEARCH_HOST=${OPENVIDU_PRO_ELASTICSEARCH_HOST:-http://127.0.0.1:9200}
@ -105,11 +106,11 @@ services:
command: command:
- --log-file=stdout - --log-file=stdout
- --external-ip=$$(detect-external-ip) - --external-ip=$$(detect-external-ip)
- --listening-port=3478 - --listening-port=${COTURN_PORT:-3478}
- --fingerprint - --fingerprint
- --lt-cred-mech - --lt-cred-mech
- --min-port=40000 - --min-port=${COTURN_MIN_PORT:-40000}
- --max-port=65535 - --max-port=${COTURN_MAX_PORT:-65535}
- --realm=openvidu - --realm=openvidu
- --verbose - --verbose
logging: logging:

View File

@ -42,6 +42,7 @@ services:
- COTURN_REDIS_IP=127.0.0.1 - COTURN_REDIS_IP=127.0.0.1
- COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET} - COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET}
- COTURN_IP=${COTURN_IP:-auto-ipv4} - COTURN_IP=${COTURN_IP:-auto-ipv4}
- COTURN_PORT=${COTURN_PORT:-3478}
- OPENVIDU_PRO_CLUSTER=true - OPENVIDU_PRO_CLUSTER=true
- OPENVIDU_PRO_KIBANA_HOST=${OPENVIDU_PRO_KIBANA_HOST:-http://127.0.0.1/kibana} - OPENVIDU_PRO_KIBANA_HOST=${OPENVIDU_PRO_KIBANA_HOST:-http://127.0.0.1/kibana}
- OPENVIDU_PRO_ELASTICSEARCH_HOST=${OPENVIDU_PRO_ELASTICSEARCH_HOST:-http://127.0.0.1:9200} - OPENVIDU_PRO_ELASTICSEARCH_HOST=${OPENVIDU_PRO_ELASTICSEARCH_HOST:-http://127.0.0.1:9200}
@ -73,12 +74,12 @@ services:
- DB_PASSWORD=${OPENVIDU_SECRET} - DB_PASSWORD=${OPENVIDU_SECRET}
command: command:
- --log-file=stdout - --log-file=stdout
- --external-ip=$$(detect-external-ip) - --external-ip=${COTURN_IP:-auto-ipv4}
- --listening-port=3478 - --listening-port=${COTURN_PORT:-3478}
- --fingerprint - --fingerprint
- --lt-cred-mech - --lt-cred-mech
- --min-port=40000 - --min-port=${COTURN_MIN_PORT:-40000}
- --max-port=65535 - --max-port=${COTURN_MAX_PORT:-65535}
- --realm=openvidu - --realm=openvidu
- --verbose - --verbose
logging: logging:

View File

@ -159,6 +159,8 @@ public class OpenviduConfig {
private String coturnIp; private String coturnIp;
private int coturnPort;
private String coturnRedisIp; private String coturnRedisIp;
// If true, coturn relay ips will come with the private IP of the machine // If true, coturn relay ips will come with the private IP of the machine
@ -328,6 +330,10 @@ public class OpenviduConfig {
return this.coturnIp; return this.coturnIp;
} }
public int getCoturnPort() {
return this.coturnPort;
}
public RecordingNotification getOpenViduRecordingNotification() { public RecordingNotification getOpenViduRecordingNotification() {
return this.openviduRecordingNotification; return this.openviduRecordingNotification;
} }
@ -589,6 +595,8 @@ public class OpenviduConfig {
checkCoturnIp(); checkCoturnIp();
checkCoturnPort();
coturnRedisIp = asOptionalInetAddress("COTURN_REDIS_IP"); coturnRedisIp = asOptionalInetAddress("COTURN_REDIS_IP");
checkWebhook(); checkWebhook();
@ -622,6 +630,14 @@ public class OpenviduConfig {
} }
} }
private void checkCoturnPort(){
String property = "COTURN_PORT";
coturnPort = this.asNonNegativeInteger(property);
if (coturnPort <= 0 || coturnPort > 65535){
log.warn("Non valid coturn port, setting to default 3478");
}
}
private void checkWebhook() { private void checkWebhook() {
openviduWebhookEnabled = asBoolean("OPENVIDU_WEBHOOK"); openviduWebhookEnabled = asBoolean("OPENVIDU_WEBHOOK");
openviduWebhookEndpoint = asOptionalURL("OPENVIDU_WEBHOOK_ENDPOINT"); openviduWebhookEndpoint = asOptionalURL("OPENVIDU_WEBHOOK_ENDPOINT");

View File

@ -172,6 +172,7 @@ public class SessionEventsHandler {
participant.getToken().getRole().name()); participant.getToken().getRole().name());
} }
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNIP_PARAM, openviduConfig.getCoturnIp()); result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNIP_PARAM, openviduConfig.getCoturnIp());
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNPORT_PARAM, openviduConfig.getCoturnPort());
if (participant.getToken().getTurnCredentials() != null) { if (participant.getToken().getTurnCredentials() != null) {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNUSERNAME_PARAM, result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNUSERNAME_PARAM,
participant.getToken().getTurnCredentials().getUsername()); participant.getToken().getTurnCredentials().getUsername());

View File

@ -46,6 +46,7 @@ public class BashCoturnCredentialsService extends CoturnCredentialsService {
log.error("No COTURN server will be automatically configured for clients"); log.error("No COTURN server will be automatically configured for clients");
} else { } else {
log.info("COTURN IP: " + this.openviduConfig.getCoturnIp()); log.info("COTURN IP: " + this.openviduConfig.getCoturnIp());
log.info("COTURN PORT: " + this.openviduConfig.getCoturnPort());
log.info("COTURN Redis DB accessible with string " + this.coturnDatabaseString); log.info("COTURN Redis DB accessible with string " + this.coturnDatabaseString);
log.info("Cleaning COTURN DB..."); log.info("Cleaning COTURN DB...");
if (response.contains("log file opened")) { if (response.contains("log file opened")) {

View File

@ -303,7 +303,7 @@ public abstract class MediaEndpoint {
if (openviduConfig.getCoturnIp() != null && !openviduConfig.getCoturnIp().isEmpty() if (openviduConfig.getCoturnIp() != null && !openviduConfig.getCoturnIp().isEmpty()
&& openviduConfig.isTurnadminAvailable()) { && openviduConfig.isTurnadminAvailable()) {
webEndpoint.setStunServerAddress(openviduConfig.getCoturnIp()); webEndpoint.setStunServerAddress(openviduConfig.getCoturnIp());
webEndpoint.setStunServerPort(3478); webEndpoint.setStunServerPort(openviduConfig.getCoturnPort());
} }
endpointLatch.countDown(); endpointLatch.countDown();