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

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