title: Angular 5.0: Proxy websocket
body: <p>I am trying to proxy websocket with angular CLI but this isn't work. </p>
  
  <p>Here is my proxy configuration proxy.conf.json</p>
  
  <pre><code>   {
            "/stream/*": {
              "target": "ws://demos.kaazing.com/echo",
              "secure": false,
              "ws": true
            }
     }
  </code></pre>
  
  <p>I run server with next parameters</p>
  
  <pre><code>"serve": {
    "port": 5000,
    "host": "0.0.0.0"
  }
  </code></pre>
  
  <p>Html code example:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;!-- Required meta tags --&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;
      &lt;title&gt;Page Title&lt;/title&gt;
      &lt;!-- Bootstrap CSS --&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;h1&gt;Hello, world!&lt;/h1&gt;
      &lt;script&gt;
      var socket = new WebSocket("ws://localhost:5000/stream/");
      // var socket = new WebSocket("ws://demos.kaazing.com/echo");
      socket.onopen = function() {
          console.log("Соединение установлено.");
      };
  
      socket.onclose = function(event) {
          if (event.wasClean) {
              console.log('Соединение закрыто чисто');
          } else {
              console.log('Обрыв соединения'); // например, "убит" процесс сервера
          }
          console.log('Код: ' + event.code + ' причина: ' + event.reason);
      };
  
      socket.onmessage = function(event) {
          console.log("Получены данные " + event.data);
      };
  
      socket.onerror = function(error) {
          console.log("Ошибка " + error.message);
      };
      &lt;/script&gt;
      &lt;!-- Optional JavaScript --&gt;
      &lt;!-- jQuery first, then Popper.js, then Bootstrap JS --&gt;
      &lt;script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"&gt;&lt;/script&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"&gt;&lt;/script&gt;
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I have error like </p>
  
  <pre><code>test.html:16 WebSocket connection to 'ws://localhost:5000/stream/' failed: Connection closed before receiving a handshake response
  </code></pre>
  
  <p>This closed issue: <a href="https://stackoverflow.com/questions/48793151/angular-cli-proxy-websocket-with-proxy-conf-json?rq=1">Angular CLI: Proxy websocket with proxy.conf.json</a> didn't help me.</p>