fix wrong ws protocol on https

This commit is contained in:
lukas 2021-05-01 17:38:12 +02:00
parent 7f89392b30
commit ab02a49b8f

View File

@ -43,7 +43,10 @@ class MovieSettings extends React.Component<Props, state> {
dial(): void { dial(): void {
console.log('trying to connect...'); console.log('trying to connect...');
const conn = new WebSocket(`ws://${window.location.host}/subscribe`); // check which ws protocol we need
const wsProt = window.location.protocol === 'http:' ? 'ws' : 'wss';
const conn = new WebSocket(`${wsProt}://${window.location.host}/subscribe`);
conn.addEventListener('close', (ev) => { conn.addEventListener('close', (ev) => {
this.appendLog(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`, true); this.appendLog(`WebSocket Disconnected code: ${ev.code}, reason: ${ev.reason}`, true);
if (ev.code !== 1001) { if (ev.code !== 1001) {