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 <[email protected]>
  • Loading branch information
Antreesy committed Dec 10, 2024
1 parent 0651a57 commit 60416d3
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
Expand Up @@ -108,6 +108,7 @@ export default {
errorMessage: '',
warningMessage: '',
versionFound: '',
socket: null,
}
},

Expand Down Expand Up @@ -172,6 +173,8 @@ export default {
features: data.features.join(', '),
})
}

await this.testWebSocketConnection(this.server)
} catch (exception) {
this.checked = true
const data = exception.response.data.ocs.data
Expand All @@ -195,6 +198,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>
Expand Down

0 comments on commit 60416d3

Please sign in to comment.