title: Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket':
body: <p>I'm trying to run this code:</p>
  
  <pre><code>function smConnect() {
    ws = new WebSocket('ws://127.0.0.1:1805/');
    delete ws.URL;
  
    ws.onopen = function(response) {};
    ws.onmessage = function(response) {};
    ws.onclose = function(response) {};
    ws.onerror = function(error) {};
  }
  
  smConnect();
  ws.send('message', 'hi');
  </code></pre>
  
  <p>But it returns me this error:</p>
  
  <blockquote>
    <p>Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.</p>
  </blockquote>
  
  <p>What could be the problem?</p>