Skip to content

Commit

Permalink
fix(AdminSettings): add test of websocket connection with HPB
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Dec 11, 2024
1 parent ac7f14f commit 42c707f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/components/AdminSettings/SignalingServer.vue
Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ export default {
errorMessage: '',
warningMessage: '',
versionFound: '',
socket: null,
}
},

@@ -162,6 +163,8 @@ export default {
features: data.features.join(', '),
})
}

await this.testWebSocketConnection(this.server)
} catch (exception) {
this.checked = true
const data = exception.response.data.ocs.data
@@ -185,6 +188,43 @@ export default {
}
}
},

async testWebSocketConnection(url) {
try {
url = url.replace(/^http/, 'ws').replace(/\/$/, '') + '/spreed'

this.socket = new WebSocket(url)
this.socket.onopen = function(event) {
console.info('Connected to websocket successfully, closing', event)
this.socket.close()
}.bind(this)
this.socket.onerror = function(event) {
console.error('Error', event)
this.socket.close()
}.bind(this)
this.socket.onclose = function(event) {
if (event.wasClean) {
console.info('Connection closed cleanly:', event)
} else {
this.errorMessage = t('spreed', 'Error: Websocket connection failed. Check browser console')
console.error('An exception occurred while testing websocket connection:', event)
switch (event.code) {
case 1006: {
console.info('Code 1006: Possible untrusted certificate')
break
}
default: {
console.info(`Code ${event.code}: Unknown exception. See https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4`)
break
}
}
}
this.socket = null
}.bind(this)
} catch (exception) {
console.error(exception)
}
},
},
}
</script>

0 comments on commit 42c707f

Please sign in to comment.