title: websockets - reject a socket connection
body: <p>I'm using <a href="https://github.com/websockets/ws" rel="nofollow">ws</a> as the socket library for my node.js library.<br>
  so my question is, how can I reject a connection if the user doesn't pass the authorization process.  </p>
  
  <pre><code>var WebSocketServer = require('ws').Server;
  var wss = new WebSocketServer({port: 6969});
  
  wss.on('connection', function(socket){
  // if the socket.upgradeReq.headers.cookie doesn't exists, reject the client
  })
  </code></pre>
  
  <p>thanks a lot</p>