Fix issue with http when server.ssl.enabled is set to false

pull/473/head
Moses Gitau 2020-05-14 10:44:56 +03:00
parent f870cbdfa9
commit bc38874a76
2 changed files with 12 additions and 4 deletions

View File

@ -1288,8 +1288,10 @@ export class Session extends EventDispatcher {
} }
} }
this.openvidu.wsUri = 'wss://' + url.host + '/openvidu'; const isHttps = token.startsWith("wss://");
this.openvidu.httpUri = 'https://' + url.host;
this.openvidu.wsUri = url.protocol + url.host + '/openvidu';
this.openvidu.httpUri = (isHttps ? 'https://': 'http://') + url.host;
} else { } else {
logger.error('Token "' + token + '" is not valid') logger.error('Token "' + token + '" is not valid')

View File

@ -565,9 +565,15 @@ public class OpenviduConfig {
this.configProps.remove("OPENVIDU_DOMAIN_OR_PUBLIC_IP"); 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()) { if (domain != null && !domain.isEmpty()) {
this.domainOrPublicIp = domain; this.domainOrPublicIp = domain;
this.openviduPublicUrl = "https://" + domain; this.openviduPublicUrl = prefix + domain;
if (this.httpsPort != null && this.httpsPort != 443) { if (this.httpsPort != null && this.httpsPort != 443) {
this.openviduPublicUrl += (":" + this.httpsPort); this.openviduPublicUrl += (":" + this.httpsPort);
} }
@ -619,7 +625,7 @@ public class OpenviduConfig {
if (publicUrl.startsWith("https://")) { if (publicUrl.startsWith("https://")) {
OpenViduServer.wsUrl = publicUrl.replace("https://", "wss://"); OpenViduServer.wsUrl = publicUrl.replace("https://", "wss://");
} else if (publicUrl.startsWith("http://")) { } else if (publicUrl.startsWith("http://")) {
OpenViduServer.wsUrl = publicUrl.replace("http://", "wss://"); OpenViduServer.wsUrl = publicUrl.replace("http://", "ws://");
} }
if (OpenViduServer.wsUrl.endsWith("/")) { if (OpenViduServer.wsUrl.endsWith("/")) {
OpenViduServer.wsUrl = OpenViduServer.wsUrl.substring(0, OpenViduServer.wsUrl.length() - 1); OpenViduServer.wsUrl = OpenViduServer.wsUrl.substring(0, OpenViduServer.wsUrl.length() - 1);