Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
I'm having trouble connecting websocket

I create a server using the SocketTest v 3.0.0 program.

socketTest

I tried to connect with JavaScript to my own server,

connect with js

When undefined appears in the console, I get a message from a javaScript client; socket test

Message is;

GET / HTTP/1.1
Host: 127.0.0.1:9090
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4655.6 Safari/537.36
Upgrade: websocket
Origin: chrome://new-tab-page
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,tr-TR;q=0.8,tr;q=0.7
Sec-WebSocket-Key: yeTxrheLM3XMmBowpT5DhQ==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

When I run ws.send("hello server") I got this error;

Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.

After waiting for a while, the client turns itself off automatically.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This Socket Test app (if that's the one you're using) creates a generic TCP server, not a webSocket server. A webSocket client MUST connect to a webSocket server. It needs something that speaks the webSocket connection protocol in order to have a successful connection and when you point it at a plain TCP server, it will send it's initial connection request, but not receive the response it expects (the first stage of the webSocket connection protocol) and thus never connect successfully.

FYI, you can see how a basic webSocket server works here on MDN and that will show you a sample of the webSocket connection protocol that a webSocket client is expecting (that your generic TCP server is not providing).

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda