您能告诉我Deepstream的设置吗?它配置了Express和Deepstream的SSL。
在尝试为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);
},
发布于 2015-07-31 13:22:45
解决方案是,对于浏览器中的客户端,我忘记了更改:
var client = deepstream('127.0.0.1:6020');
至:
var client = deepstream('wss://127.0.0.1:6020');
答案很简单,显而易见。:-)
发布于 2019-04-26 11:07:59
添加一个简单的代码来演示这一点。
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;
https://stackoverflow.com/questions/31747079
复制