Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
NodeJS websocket not responding properly

I'm extremely new to any kind of web-development so sorry in before-hand if what I write makes no sense. I'm working on a website that can get and post data through a website to a machine. (Client/Browser <-> Webserver <-> Machine). I'm having a problem though opening a websocket to be used by the Webserver <-> Machine connection. I use Javascript since I couldn't find any other viable solution to make this work. My code looks like this:

const WebSocket = require('ws');
const webSocketServer = new WebSocket.Server({port: 4000});

webSocketServer.on('request', function(request) {
  console.log("test!");

  const connection = request.accept(null, request.origin);
});   

I use npm to start the web server and there are no errors, warnings or crashes. When I use postman however to send a GET request it gives the code "426: Upgrade Required" But I'm guessing that's simply because I don't do anything yet with the connection. My main problem is the the console is not logging the "test!" when I send out this request. What am I doing wrong? Is there a better solution to this that I'm not seeing?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda