Настройка HTTPS и WSS для Deepstream?

Не могли бы вы указать мне на настройку Deepstream с SSL, настроенным для Express и Deepstream?

Я в первую очередь вижу следующую ошибку после попытки настройки для https и wss. Кроме того, я использую самозаверяющий сертификат.

Смешанное содержимое: страница «https://127.0.0.1:8082/» была загружена через HTTPS, но запросил небезопасную конечную точку XMLHttpRequest 'http://127.0.0.1:6020/engine.io/?EIO=3&transport=polling '. Этот запрос заблокирован; контент должен обслуживаться по HTTPS.

initializeKeys : function() {
    this.ssl = {};
    this.ssl.cert = fs.readFileSync('./keys/cert.pem', 'utf8');
    this.ssl.key = fs.readFileSync('./keys/key.pem', 'utf8');
},

initializeSecureWebServer: function() {
    var fs = require('fs');
    var https = require('https');
    var credentials = {key: this.ssl.key, cert: this.ssl.cert};
    var express = require('express');
    var app = express();
    app.use('/', express.static(__dirname + '/../client'));
    app.use('/shell', express.static(__dirname + '/../shell'));
    var server = https.createServer(credentials, app);
    server.listen(8082);
},

initializeDeepstreamServer: function() {
    this.server = new DeepstreamServer();
    this.server.set('host', '127.0.0.1');
    this.server.set('port', 6020);
    this.server.set('sslCert', this.ssl.cert);
    this.server.set('sslKey', this.ssl.key);
},

person philmaker    schedule 31.07.2015    source источник


Ответы (2)


Решение заключалось в том, что для клиента в браузере я забыл изменить:

var client = deepstream('127.0.0.1:6020');

to:

var client = deepstream('wss://127.0.0.1:6020');

Есть простой очевидный ответ. :-)

person philmaker    schedule 31.07.2015

Добавляем простой код, чтобы продемонстрировать это.

const ds = require('deepstream.io-client-js');

const client = ds('wss://127.0.0.1:6020', {
  subscriptionTimeout: 500000,
}).login();

client.on('error', (msg, event, topic) => {
  console.error(`[${event}][${topic}]  Deepstream Error: ${msg}`);
});

// Client A
client.event.subscribe('dp/channel', data => {
  // handle published data
console.log(data);
})

// Client B
client.event.emit('dp/channel', { some: 'data1' });
module.exports = client;
person azhar    schedule 26.04.2019