diff --git a/openvidu-browser/src/OpenVidu/Session.ts b/openvidu-browser/src/OpenVidu/Session.ts index a5cc5240..e5034bd2 100644 --- a/openvidu-browser/src/OpenVidu/Session.ts +++ b/openvidu-browser/src/OpenVidu/Session.ts @@ -1288,8 +1288,10 @@ export class Session extends EventDispatcher { } } - this.openvidu.wsUri = 'wss://' + url.host + '/openvidu'; - this.openvidu.httpUri = 'https://' + url.host; + const isHttps = token.startsWith("wss://"); + + this.openvidu.wsUri = url.protocol + url.host + '/openvidu'; + this.openvidu.httpUri = (isHttps ? 'https://': 'http://') + url.host; } else { logger.error('Token "' + token + '" is not valid') diff --git a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java index 27c82131..ae29f718 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java +++ b/openvidu-server/src/main/java/io/openvidu/server/config/OpenviduConfig.java @@ -565,9 +565,15 @@ public class OpenviduConfig { this.configProps.remove("OPENVIDU_DOMAIN_OR_PUBLIC_IP"); } + String sslEnabled = getValue("server.ssl.enabled"); + if(sslEnabled == null){ + sslEnabled = getValue("SERVER_SSL_ENABLED"); + } + String prefix = sslEnabled.equalsIgnoreCase("false") ? "http://": "https://"; + if (domain != null && !domain.isEmpty()) { this.domainOrPublicIp = domain; - this.openviduPublicUrl = "https://" + domain; + this.openviduPublicUrl = prefix + domain; if (this.httpsPort != null && this.httpsPort != 443) { this.openviduPublicUrl += (":" + this.httpsPort); } @@ -619,7 +625,7 @@ public class OpenviduConfig { if (publicUrl.startsWith("https://")) { OpenViduServer.wsUrl = publicUrl.replace("https://", "wss://"); } else if (publicUrl.startsWith("http://")) { - OpenViduServer.wsUrl = publicUrl.replace("http://", "wss://"); + OpenViduServer.wsUrl = publicUrl.replace("http://", "ws://"); } if (OpenViduServer.wsUrl.endsWith("/")) { OpenViduServer.wsUrl = OpenViduServer.wsUrl.substring(0, OpenViduServer.wsUrl.length() - 1);