onError
The error event is triggered when the browsers websocket API fires a error event. Below we catch errors by having autoreconnect set to true and then try to connect to a server that is not available so that we will get a connection error every 5 seconds.
<script>
    var conn = new xsockets.client('ws://localhost:666');
    conn.autoReconnect(true);
    conn.onError = function (e) {
        console.log('Error occured', e);
    }
    conn.open();
</script>