title: WebSocket, even after firing onopen event, still in CONNECTING state
body: <p>WebSocket send method throws exception even on trying after onconnect.
  Not always, but many times I see the logged exceptions in console.</p>
  
  <p>This is the typescript code:-</p>
  
  <pre><code>  open() {
      if ('WebSocket' in window) {
        this.ws = new WebSocket(ApiUrls.Socket(''));
        this.ws.onopen = () =&gt; {
          const authentication = {
            msgType : 'Authenticate',
            data : {
              token : localStorage.getItem('authToken')
            }
          }
          this.ws.send(JSON.stringify(authentication));
        };
  
        this.ws.onmessage = (evt) =&gt; {
          // console.log(evt);
          this.parseMessage(evt.data);
        };
  
        this.ws.onclose = () =&gt; {
          this.connected = false;
          // console.log('retrying connection with server');
          if (localStorage.getItem('authToken')) {
            this.reconnectTimeout = setTimeout(this.open.bind(this), 1000);
          }
        };
      } else {
        alert('WebSocket NOT supported by your Browser!');
      }
    }
  </code></pre>
  
  <p>Exception in console:-</p>
  
  <pre><code>ERROR DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
      at WebSocket.ws.onopen [as __zone_symbol__ON_PROPERTYopen] (http://localhost:4200/main.bundle.js:5586:26)
      at WebSocket.wrapFn (http://localhost:4200/polyfills.bundle.js:3711:39)
      at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:2970:31)
      at Object.onInvokeTask (http://localhost:4200/vendor.bundle.js:87677:33)
      at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:2969:36)
      at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (http://localhost:4200/polyfills.bundle.js:2737:47)
      at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.bundle.js:3044:34)
      at invokeTask (http://localhost:4200/polyfills.bundle.js:4085:14)
      at WebSocket.globalZoneAwareCallback (http://localhost:4200/polyfills.bundle.js:4111:17)
  </code></pre>
  
  <p>It's too verbose, but concerned message is, <code>ERROR DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
          at WebSocket.ws.onopen [as __zone_symbol__ON_PROPERTYopen]</code>.</p>