diff --git a/connect/src/core.ts b/connect/src/core.ts index 92a4cc629..0304d64f2 100644 --- a/connect/src/core.ts +++ b/connect/src/core.ts @@ -193,7 +193,7 @@ export default class Ad4mConnect { if (data.serviceId) { this.setPort(data.port); this.setUrl(data.url); - + this.isHosting = true; setForVersion('ad4mhosting', 'true'); @@ -297,15 +297,7 @@ export default class Ad4mConnect { try { const websocket = new WebSocket(this.url); - websocket.onerror = (error) => { - this.notifyConnectionChange("not_connected"); - }; - setTimeout(() => { - if (websocket.readyState !== WebSocket.OPEN) { - this.notifyConnectionChange("not_connected"); - } - }, 10000); } catch (e) { this.notifyConnectionChange("not_connected"); return; @@ -315,6 +307,8 @@ export default class Ad4mConnect { this.requestedRestart = true; this.wsClient.dispose(); this.apolloClient.stop(); + this.wsClient = null; + this.apolloClient = null; } this.wsClient = createClient({ diff --git a/connect/src/utils.ts b/connect/src/utils.ts index a5199418c..37294c1d4 100644 --- a/connect/src/utils.ts +++ b/connect/src/utils.ts @@ -14,12 +14,15 @@ export async function connectWebSocket(url, timeout = 10000) { return Promise.race([ new Promise((resolve, reject) => { try { + if (url.includes("proxy")) { + resolve(new WebSocket(url)); + } const websocket = new WebSocket(url); - + websocket.onopen = () => { resolve(websocket); }; - + websocket.onerror = (error) => { reject(error); };