diff --git a/src/component/internal/reconnector/webrtc.ts b/src/component/internal/reconnector/webrtc.ts index 5505e5d3..ec1688cf 100644 --- a/src/component/internal/reconnector/webrtc.ts +++ b/src/component/internal/reconnector/webrtc.ts @@ -33,6 +33,10 @@ export class WebrtcReconnector extends ReconnectorAbstract { } public connect() { + if (this._webrtc.connected) { + this._webrtc.disconnect() + } + if (this._websocket.connected) { this._websocket.send(EVENT.SIGNAL_REQUEST, { video: this._state.webrtc.video }) } diff --git a/src/component/internal/reconnector/websocket.ts b/src/component/internal/reconnector/websocket.ts index 238f10d1..0b4da406 100644 --- a/src/component/internal/reconnector/websocket.ts +++ b/src/component/internal/reconnector/websocket.ts @@ -29,6 +29,10 @@ export class WebsocketReconnector extends ReconnectorAbstract { } public connect() { + if (this._websocket.connected) { + this._websocket.disconnect() + } + let url = this._state.url url = url.replace(/^http/, 'ws').replace(/\/+$/, '') + '/api/ws'