Git Product home page Git Product logo

Comments (6)

Alcaros avatar Alcaros commented on September 23, 2024 2

Problem solved.

  protocolOptions: {
    key: fs.readFileSync(__dirname + '/privkey.pem'),
    cert: fs.readFileSync(__dirname + '/fullchain.pem')
}

Change cert.pem to fullchain.pem. (letsencrypt cert)

from socketcluster-client.

zalmoxisus avatar zalmoxisus commented on September 23, 2024 1

You should use secure: true instead of protocol: 'https' in socketcluster-client.

from socketcluster-client.

Alcaros avatar Alcaros commented on September 23, 2024

This is host options

var options = {
  host: 'localhost',
  workers: Number(argv.w) || Number(process.env.SOCKETCLUSTER_WORKERS) || 3,
  brokers: Number(argv.b) || Number(process.env.SOCKETCLUSTER_BROKERS) || 1,
  port: Number(argv.p) || Number(process.env.SOCKETCLUSTER_PORT) || 8500,
  // If your system doesn't support 'uws', you can switch to 'ws' (which is slower but works on older systems).
  wsEngine: process.env.SOCKETCLUSTER_WS_ENGINE || 'uws',
  appName: argv.n || process.env.SOCKETCLUSTER_APP_NAME || null,
  workerController: workerControllerPath || __dirname + '/worker.js',
  brokerController: brokerControllerPath || __dirname + '/broker.js',
  initController: initControllerPath || null,
  socketChannelLimit: Number(process.env.SOCKETCLUSTER_SOCKET_CHANNEL_LIMIT) || 1000,
  clusterStateServerHost: argv.cssh || process.env.SCC_STATE_SERVER_HOST || null,
  clusterStateServerPort: process.env.SCC_STATE_SERVER_PORT || null,
  clusterAuthKey: process.env.SCC_AUTH_KEY || null,
  clusterStateServerConnectTimeout: Number(process.env.SCC_STATE_SERVER_CONNECT_TIMEOUT) || null,
  clusterStateServerAckTimeout: Number(process.env.SCC_STATE_SERVER_ACK_TIMEOUT) || null,
  clusterStateServerReconnectRandomness: Number(process.env.SCC_STATE_SERVER_RECONNECT_RANDOMNESS) || null,
  crashWorkerOnError: argv['auto-reboot'] != false,
  pingTimeout: 1800000,
  protocol: 'https',
  protocolOptions: {
    key: fs.readFileSync(__dirname + '/privkey.pem', 'utf8'),
    cert: fs.readFileSync(__dirname + '/cert.pem', 'utf8'),
    passphrase: ''
  },
  socketUpgradeTimeout: 5000,
  logLevel: 2
};

from socketcluster-client.

jondubois avatar jondubois commented on September 23, 2024

That's such a common mistake, I should probably make the client throw an error or something...

from socketcluster-client.

Alcaros avatar Alcaros commented on September 23, 2024

I trying option secure: true and it stills hung up.

from socketcluster-client.

Alcaros avatar Alcaros commented on September 23, 2024

I create a simple page for test wss/ws connection at http://mylive.in.th/testwebsocket
It works fine on browser both wss/ws but can connect only ws:// websocket server with nodejs.

<body>
        <div><strong>Secured Websocket Connection (port:8500)</strong></div>
        <div id="socket1"></div>
        <div><strong>Unsecured Websocket Connection (port:80)</strong></div>
        <div id="socket2"></div>
    </body>

    <script src="//jquery/jquery-3.1.1.min.js"></script>
    <script src="//socketcluster/socketcluster.min.js"></script>

    <script>
    // Secured websocket connection
    var socket = socketCluster.connect({
        hostname: 'chat.socket3.mylive.in.th',
        secure: true,
        port: 8500
    });

    // Unsecured websocket connection
    var socket2 = socketCluster.connect({
        hostname: 'chat.socket3.mylive.in.th',
        secure: false,
        port: 80
    });

    socket.on('error', function(e){
        $("#socket1").html(e.name);
        console.log(e);
    });

    socket.on('connect', function(status){
        $("#socket1").html("connected");
    });

    socket2.on('error', function(e){
        $("#socket2").html(e.name);
        console.log(e);
    });

    socket2.on('connect', function(status){
        $("#socket2").html("connected");
    });
    </script>

from socketcluster-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.