title: "Upgrade Required" (ws package) WebSockets with Node
body: <p>I would like to simply use WebSockets with Node js. I show you my code :</p>
  
  <p><strong>index.html</strong> </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;WebSockets&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;script type="text/javascript"&gt;
  
      const WebSocket = require('ws');
  
      var sock = new WebSocket("ws://localhost:5001",{perMessageDeflate:false});
  
      sock.onopen = function(event){
          alert('Socket connected successfully');
          setTimeout(function(){
              sock.send("Hey !");
          },1000);
      };
      sock.onmessage = function(event){
          console.log(event);
      };
  
      &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>index.js</strong></p>
  
  <pre><code>var server = require('ws').Server;
  var s = new server({ port:5001});
  </code></pre>
  
  <p>I installed the package " ws " to use WebSockets. My first aim is to simply console.log something. </p>
  
  <p>However, I have this error... <strong>" Upgrade Required "</strong> with the status 426 on my GET Request. </p>
  
  <p>(I have been following an online Tutoriel <a href="https://www.youtube.com/watch?v=TPLAd-j9tMs" rel="nofollow noreferrer">https://www.youtube.com/watch?v=TPLAd-j9tMs</a>) but I get this error...</p>
  
  <p>One should bear in mind that the documentation of this package says : "Note: This module does not work in the browser. The client in the docs is a reference to a back end with the role of a client in the WebSocket communication. Browser clients must use the native WebSocket object."</p>
  
  <p>So it may explain the problem but in this case how to use "the native Websocket object" ?</p>
  
  <p>Thanks in advance ! </p>