Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
ws.message no está definido Error, respuesta de Web Socket

Soy desarrollador de Python, pero necesito ver la salida de mi websocket desde el navegador.

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

este es mi archivo cliente.js.

 <!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>

y este es mi archivo html. Estoy enviando una cadena desde mi socket web y quiero ver el interior de un navegador. Cuando ejecuto este html, mi socket web comienza a funcionar pero mis registros dicen indefinido.

Esta es mi salida de registro

 client.js:6 undefined client.js:7 test client.js:8 undefined
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

leer más aquí

vincular a los controladores de eventos correctos

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!