Skip to content

Commit

Permalink
Coturn port conf
Browse files Browse the repository at this point in the history
  • Loading branch information
gtunon committed Oct 1, 2021
1 parent 2e5f605 commit 57faf14
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 13 deletions.
4 changes: 2 additions & 2 deletions openvidu-browser/src/OpenVidu/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1526,8 +1526,8 @@ export class Session extends EventDispatcher {

private processJoinRoomResponse(opts: LocalConnectionOptions) {
this.sessionId = opts.session;
if (opts.coturnIp != null && opts.turnUsername != null && opts.turnCredential != null) {
const turnUrl1 = 'turn:' + opts.coturnIp + ':3478';
if (opts.coturnIp != null && opts.coturnPort != null && opts.turnUsername != null && opts.turnCredential != null) {
const turnUrl1 = 'turn:' + opts.coturnIp + ':' + opts.coturnPort;
this.openvidu.iceServers = [
{ urls: [turnUrl1], username: opts.turnUsername, credential: opts.turnCredential }
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface LocalConnectionOptions {
role: string;
record: boolean;
coturnIp: string;
coturnPort: string;
turnUsername: string;
turnCredential: string;
version: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public class ProtocolElements {
public static final String PARTICIPANTJOINED_RECORD_PARAM = "record";
public static final String PARTICIPANTJOINED_ROLE_PARAM = "role";
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_TURNCREDENTIAL_PARAM = "turnCredential";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ services:
- COTURN_REDIS_IP=127.0.0.1
- COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET}
- COTURN_IP=${COTURN_IP:-auto-ipv4}
- COTURN_PORT=${COTURN_PORT:-3478}
logging:
options:
max-size: "${DOCKER_LOGS_MAX_SIZE:-100M}"
Expand Down Expand Up @@ -84,11 +85,11 @@ services:
- DB_PASSWORD=${OPENVIDU_SECRET}
command:
- --log-file=stdout
- --listening-port=3478
- --listening-port=${COTURN_PORT:-3478}
- --fingerprint
- --lt-cred-mech
- --min-port=57001
- --max-port=65535
- --min-port=${COTURN_MIN_PORT:-57001}
- --max-port=${COTURN_MIN_PORT:-65535}
- --realm=openvidu
- --verbose
logging:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
- COTURN_REDIS_IP=127.0.0.1
- COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET}
- COTURN_IP=${COTURN_IP:-auto-ipv4}
- COTURN_PORT=${COTURN_PORT:-3478}
- OPENVIDU_PRO_CLUSTER=true
- 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}
Expand Down Expand Up @@ -105,11 +106,11 @@ services:
command:
- --log-file=stdout
- --external-ip=$$(detect-external-ip)
- --listening-port=3478
- --listening-port=${COTURN_PORT:-3478}
- --fingerprint
- --lt-cred-mech
- --min-port=40000
- --max-port=65535
- --min-port=${COTURN_MIN_PORT:-40000}
- --max-port=${COTURN_MAX_PORT:-65535}
- --realm=openvidu
- --verbose
logging:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ services:
- COTURN_REDIS_IP=127.0.0.1
- COTURN_REDIS_PASSWORD=${OPENVIDU_SECRET}
- COTURN_IP=${COTURN_IP:-auto-ipv4}
- COTURN_PORT=${COTURN_PORT:-3478}
- OPENVIDU_PRO_CLUSTER=true
- 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}
Expand Down Expand Up @@ -73,12 +74,12 @@ services:
- DB_PASSWORD=${OPENVIDU_SECRET}
command:
- --log-file=stdout
- --external-ip=$$(detect-external-ip)
- --listening-port=3478
- --external-ip=${COTURN_IP:-auto-ipv4}
- --listening-port=${COTURN_PORT:-3478}
- --fingerprint
- --lt-cred-mech
- --min-port=40000
- --max-port=65535
- --min-port=${COTURN_MIN_PORT:-40000}
- --max-port=${COTURN_MAX_PORT:-65535}
- --realm=openvidu
- --verbose
logging:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public String toString() {

private String coturnIp;

private int coturnPort;

private String coturnRedisIp;

// If true, coturn relay ips will come with the private IP of the machine
Expand Down Expand Up @@ -328,6 +330,10 @@ public String getCoturnIp() {
return this.coturnIp;
}

public int getCoturnPort() {
return this.coturnPort;
}

public RecordingNotification getOpenViduRecordingNotification() {
return this.openviduRecordingNotification;
}
Expand Down Expand Up @@ -589,6 +595,8 @@ protected void checkConfigurationProperties(boolean loadDotenv) {

checkCoturnIp();

checkCoturnPort();

coturnRedisIp = asOptionalInetAddress("COTURN_REDIS_IP");

checkWebhook();
Expand Down Expand Up @@ -622,6 +630,14 @@ private void checkCoturnIp() {
}
}

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() {
openviduWebhookEnabled = asBoolean("OPENVIDU_WEBHOOK");
openviduWebhookEndpoint = asOptionalURL("OPENVIDU_WEBHOOK_ENDPOINT");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public void onParticipantJoined(Participant participant, String sessionId, Set<P
participant.getToken().getRole().name());
}
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNIP_PARAM, openviduConfig.getCoturnIp());
result.addProperty(ProtocolElements.PARTICIPANTJOINED_COTURNPORT_PARAM, openviduConfig.getCoturnPort());
if (participant.getToken().getTurnCredentials() != null) {
result.addProperty(ProtocolElements.PARTICIPANTJOINED_TURNUSERNAME_PARAM,
participant.getToken().getTurnCredentials().getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private void initialize() {
log.error("No COTURN server will be automatically configured for clients");
} else {
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("Cleaning COTURN DB...");
if (response.contains("log file opened")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void onSuccess(WebRtcEndpoint result) throws Exception {
if (openviduConfig.getCoturnIp() != null && !openviduConfig.getCoturnIp().isEmpty()
&& openviduConfig.isTurnadminAvailable()) {
webEndpoint.setStunServerAddress(openviduConfig.getCoturnIp());
webEndpoint.setStunServerPort(3478);
webEndpoint.setStunServerPort(openviduConfig.getCoturnPort());
}

endpointLatch.countDown();
Expand Down

0 comments on commit 57faf14

Please sign in to comment.