Skip to main content
3 de 3
tags editadas
stderr
  • 30,9mil
  • 5
  • 49
  • 76

Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket'

Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.(index):29 (anonymous function)

Código:

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');

O que pode ser?

Vinícius Lara
  • 3,8mil
  • 3
  • 29
  • 64