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

258
Visualizações
ws.message is undefined Error, Web Socket response

I am python developer but i need to see my websocket output from browser.

function startSocket() {
    var ws = new WebSocket("ws://localhost:8765/")
    ws.onopen = function(event) {
        ws.send("Sent this from client.js")
        console.log(typeof ws.message);
        console.log("test")
        console.log(ws.message)
    }
}
startSocket();

this is my clien.js file.

<!DOCTYPE html><html lang="en">
  <head>
<!--    <link rel="stylesheet" type="text/css" href="style.css">-->
    <link type="text/css" href="styles.css">
    <meta charset="utf-8">

  </head>
  <body>
    <script src="client.js"></script>

</body></html>

and this is my html file. I am sending a string from my web socket and i want to see inside of a browser. When i run this html, my web socket is starting to work but my logs are saying undefined.

This is my Log Output

client.js:6 undefined
client.js:7 test
client.js:8 undefined
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

read more here

bind to the correct event handlers

function startSocket() {
    var ws = new WebSocket("ws://localhost:8765/");
    ws.onopen = function(event) {
        console.log("connection opened");
        ws.send("Sent this from client.js")
    };
    ws.onmessage = function(message) {
        console.log(typeof message);
        console.log("test")
        console.log(message)
    };
};
startSocket();
about 4 years ago · Santiago Gelvez 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