onAuthenticationFailed
This event is not available in the browser websocket API. The event comes from the xsockets server and will be triggered if the authentication pipeline returns false in the GetPrincipal
method. By default it returns true, so it can only return false if you implement a custom authentication pipeline (search the docs for IXSocketAuthenticationPipeline
).
<script>
var conn = new xsockets.client('ws://localhost:4502');
conn.onClose = function() {
console.log("Connection closed");
};
conn.onAuthenticationFailed = function (e) {
console.log('Authentication failed', e);
};
conn.open();
</script>
To test this I had a simple AuthenticationPipeline that always return false (just for testing).
The client will then fire the onAuthenticationFailed
event followed by a onClose
event.
Output
Authentication failed "Your connection could not be authentiacted"
Connection closed