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

175
Views
Using ws and wss simultaneously

I am trying to get both ws and wss working, on one WebSocket server.

This is what I currently have, only wss

var WebSocket = require('ws');
var https = require('https');

var privateKey = fs.readFileSync('cert/key.key');
var certificate = fs.readFileSync('cert/cert.crt');

var httpsServer = https.createServer({
    ca: ca,
    key: privateKey,
    cert: certificate
}, this.app);

var options = {
    server: httpsServer, 
    perMessageDeflate: false,
    maxPayload: 4096
};

var wss = new WebSocket.Server(options);

I know using Socket.io it is really easy, you can just do io.attach(httpServer) and io.attach(httpsServer).

var httpServer = http.createServer(this.app);
var httpsServer = https.createServer({
    key: privateKey,
    cert: certificate
}, this.app);

httpServer.listen(3002, function(){
    console.log('httpServer listening on port 3002');
});

httpsServer.listen(3003, function(){
    console.log('httpsServer listening on port 3003');
});

this.io = new ioServer();
this.io.attach(httpServer);
this.io.attach(httpsServer);

Is this even possible, using this WebSocket library?

over 4 years ago · Santiago Trujillo
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!