deepstreamIO / deepstream.io

deepstream.io server
https://deepstreamio.github.io
MIT License
7.14k stars 381 forks source link

Can't connect to SSL server (Node.js) #1052

Closed caracal7 closed 4 years ago

caracal7 commented 4 years ago

I'm trying to use Deepstream.io server/client on Zinq7020 board with ARM CPU and Ubuntu based Linux with Node.js v11.6.0 installed. Deepstream 5.0.12

Without SSL everything works perfect in browser and Node.js.

But if I use SSL then remote browsers is connected but Node.js client hangs on client.login method.

Server code

const fs = require('fs');
const path = require('path');
const { Deepstream } = require( '@deepstream/server' );

const keyUrl = name => path.resolve(__dirname, '../certs', name);
const keyFile = name => fs.readFileSync(keyUrl(name), 'utf8');

const server = new Deepstream({
    logLevel: 'DEBUG',
    httpServer: {
        type: 'default',
        options: {
            port: 6020,
            host: '192.168.1.142',
            allowAllOrigins: true,
            ssl: {
                key: keyFile("privkey.pem"),    
                cert: keyFile("fullchain.pem"),
            }
        }
    },
});
const Permission = require('./permission.js');
server.set('permission', new Permission({}, server.getServices()));
server.set('authentication', require('./authentication.js'));
server.start()

Node.js client

process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
const { DeepstreamClient } = require('@deepstream/client');
const client = new DeepstreamClient('wss://localhost:6020');
//const client = new DeepstreamClient('localhost:6020');
//const client = new DeepstreamClient('wss://localhost:6021');
//const client = new DeepstreamClient('localhost:6021');
client.login( {
    username: 'user',
    password: 'pass'
}, async (valid, args) => {
        console.log(args)
    if( valid ) {
        client.whoami.username = options.username;
        resolve(client);
    }
    else reject(Error(args.reason));
});
caracal7 commented 4 years ago

Everything is worked.

Sorry