title: AWS API Gateway Websocket - Chrome: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received
body: <p>I'm trying to use AWS API Gateway's WebSocket functionality for communication with my Angular Application. As per enterprise requirement, It is required for me to secure my WebSocket endpoint with an OAuth token.</p>
  
  <p>I have written an custom OAuth authorizer for validating OAuth token.</p>
  
  <p>This Custom authorizer is working fine with my REST endpoints.</p>
  
  <p>As per my understanding, browsers cannot support custom headers for WebSocket (<a href="https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api">HTTP headers in Websockets client API</a>).</p>
  
  <p>So as to bypass this limitation, I am using Sec-WebSocket-Protocol header for passing my OAuth token for authentication purpose.</p>
  
  <p>(Query string based authentication might not work for me as, I would exceed the URL string limitations)</p>
  
  <p>I have configured my API Gateway's configuration to accept Sec-WebSocket-Protocol as authentication header &amp; everything seems to be working fine with WSCAT utility.</p>
  
  <p>When I am integrating this endpoint with my Angular Client using RxJS (<a href="https://rxjs-dev.firebaseapp.com/api/webSocket/webSocket" rel="nofollow noreferrer">https://rxjs-dev.firebaseapp.com/api/webSocket/webSocket</a>) this entire solution works fine in FireFox &amp; Edge Browser, But Chrome throws an Handshake exception i.e. </p>
  
  <p><code>WebSocket connection to 'wss://xxxx.com/' failed: Error during WebSocket handshake: Sent non-empty 'Sec-WebSocket-Protocol' header but no response was received</code></p>
  
  <p><strong>Request Headers:</strong></p>
  
  <pre><code>GET wss://xxxx.com/ HTTP/1.1
  Host: xxxx.com
  Connection: Upgrade
  Pragma: no-cache
  Cache-Control: no-cache
  Upgrade: websocket
  Origin: http://localhost:4200
  Sec-WebSocket-Version: 13
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36
  Accept-Encoding: gzip, deflate, br
  Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
  Sec-WebSocket-Key: asdf
  Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
  Sec-WebSocket-Protocol: asdf
  </code></pre>
  
  <p><strong>Response Headers:</strong></p>
  
  <pre><code>HTTP/1.1 101 Switching Protocols
  Connection: upgrade
  Date: Tue, 11 Jun 2019 06:15:43 GMT
  upgrade: websocket
  sec-websocket-accept: asdf
  sec-websocket-extensions: permessage-deflate
  X-Cache: Miss from cloudfront
  Via: 1.1 asdf
  X-Amz-Cf-Pop: BOM51
  X-Amz-Cf-Id: asdf
  </code></pre>