title: How to handle authentication errors in socket.io with socketio-jwt
body: <p>Following the example for <a href="https://github.com/auth0/socketio-jwt" rel="nofollow">https://github.com/auth0/socketio-jwt</a> , I couldn't get the authentication failure to fire.</p>
  
  <p>How are you supposed to handle and configure authentication errors using this library?  I see in the source code that it is supposed to throw an <code>UnauthorizedError</code> but I just can't seem to trigger it.</p>
  
  <p>Server side</p>
  
  <pre><code>  io
      .on('connection', socketioJwt.authorize({
        secret: 'test',
        timeout: 7000
      }))
      .on('authenticated', (socket) =&gt; {
        console.log('connected user: ' + socket.decoded_token.name);
      });
  </code></pre>
  
  <p>Client side</p>
  
  <pre><code>  socket.on('connect', function () {
      socket.emit('authenticate', {token: 'badtoken'}); //send the jwt
    });
  
    socket.on("error", function(error) {
      // this never fires
      if (error.type == "UnauthorizedError" || error.code == "invalid_token") {
        alert("User's token has expired");
      }
    });
  </code></pre>
  
  <p>Do I need to add an <code>.on('error, function(error))</code> on the server code as well?</p>