title: nodeJS how to send a message with connection request
body: <p>I am using websockets to talk with server but I want to prevent client from connecting if a requirement is not met.  My code is very simple</p>
  <pre><code>let socket = new WebSocket('wss://server.com/server/');
  
  socket.addEventListener('open', function(e) {
    // we are now connected 
  });
  </code></pre>
  <p>How does nodeJS connect?  It must send a connect message right?  Is there a way to edit that message?  I'd like to limit it so connections can not be made unless a key is sent with the connection message.</p>
  <p>How it works now I send a &quot;login request message&quot; and if the credentials dont match I terminate the connection but currently people could still open connections without sending the login request.  This would be a security issue right?  People could just DDOS by creating a bunch of connections without logging in.</p>