Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7917907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:19:06+00:00 2026-06-03T15:19:06+00:00

How do I install an https/ssl certificate (and key) in sockjs (running on nodejs)?

  • 0

How do I install an https/ssl certificate (and key) in sockjs (running on nodejs)?

I’m currently running the most basic setup, this is, the “echo” example setup. It is a follows:

var http = require('http');
var sockjs = require('sockjs');
var node_static = require('node-static');

// 1. Echo sockjs server
var sockjs_opts = {sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"};

var sockjs_echo = sockjs.createServer(sockjs_opts);
sockjs_echo.on('connection', function(conn) {
    conn.on('data', function(message) {
        conn.write(message);
    });
});

// 2. Static files server
var static_directory = new node_static.Server(__dirname);

// 3. Usual http stuff
var server = http.createServer();
server.addListener('request', function(req, res) {
    static_directory.serve(req, res);
});
server.addListener('upgrade', function(req,res){
    res.end();
});

sockjs_echo.installHandlers(server, {prefix:'/echo'});

console.log(' [*] Listening on 0.0.0.0:9999' );
server.listen(9999, '0.0.0.0');

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:19:11+00:00Added an answer on June 3, 2026 at 3:19 pm

    Okay I got it to work by changing the code to:

    var http = require('https');
    var sockjs = require('sockjs');
    var fs = require("fs");
    
    var options = {
      key: fs.readFileSync('ssl.key'),
      cert: fs.readFileSync('ssl.crt')
    };
    
    var echo = sockjs.createServer();
    echo.on('connection', function(conn) {
        conn.on('data', function(message) {
            conn.write(message);
        });
        conn.on('close', function() {});
    });
    
    var server = http.createServer(options);
    echo.installHandlers(server, {prefix:'/echo'});
    server.listen(9999, '0.0.0.0');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is active at https://serverfault.com/questions/67844/renew-a-ssl-cert-on-iis6 . Thanks. My manager ordered a new wild
i want to install android sdk to eclipse but the path name https://dl-ssl.google.com/android/eclipse/ and
I believe I've got this setup correctly for the most part but I'm having
Im using a linux machine, and I followed the instructions seen on https://www.php.net/manual/en/install.php to
We are trying to install: http://www.activecampaign.com/activespell/ But are getting this JS error: [CPAINT Error]
I want to install this python package: http://pypi.python.org/pypi/netifaces/0.5 But I don't know how and
I've installed a UC Multi-Domain SSL Certificate from Entrust for use with two OpenCart
I'm getting this error when I try and install node on my new mac
Failed to fetch URL https://dl-ssl.google.com/android/repository/repository.xml , reason: Connection timed out: connect I've encountered above
im having this problem. everytime i try to install something using channels i get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.