如果使用任何自定义插件,则无法连接到 DeepStream Node.js 服务器

问题描述

所以,如果我使用我的 DeepStream 服务器如下

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

const server = new Deepstream({

server.start()

它工作得很好我可以从我的前端应用程序连接到它,如下所示

const {DeepstreamClient} = require('@deepstream/client')
const client = new DeepstreamClient('192.168.88.238:6020')
client.login()

但是如果我添加 MongoDB 存储实例或 RethinkDB NPM - RethinkDB

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

const server = new Deepstream({
    storage: {
        name: 'rethinkdb',options: {
            host: 'localhost',port: 28015
        }
    }
})

// start the server
server.start()

我在尝试访问我的 ds 服务器时收到以下错误消息。 (我也尝试通过 WSS:// 而不是 WS:// 进行连接)

enter image description here

解决方法

所以大家好,和我有同样的问题... 我想到了! 所以首先,npm 包文档从 Mongo DB 驱动程序的使用中说的是完全没有数据

他们怎么说你应该如何使用 npm 包:

gcc <program file> -lncurses

而不是这一切!

您并不是真的需要 var Deepstream = require( 'deepstream.io' ),MongoDBStorageConnector = require( 'deepstream.io-storage-mongodb' ),server = new Deepstream(); server.set( 'storage',new MongoDBStorageConnector( { connectionString: 'mongodb://test:test@paulo.mongohq.com:10087/munchkin-dev',splitChar: '/' })); server.start(); ,因为它是一个旧模块(基于:enter image description here),而且您真的不需要以这种方式使用...

MongoDB 连接器的正确用法:

'deep stream.io-storage-MongoDB'

或者你也可以创建一个配置。 yaml 文件来自所有这些:

const {Deepstream} = require('@deepstream/server');
const server = new Deepstream({
    storage: {
        name: "mongodb",options: {
            connectionString: MONGO_CONNECTION_STRING,splitChar: '/'
        }
    }
});

server.start();

并将其传递给深流构造函数,如下所示:

storage:
  name: mongodb
  options:
    connectionString: 'MONGO_CONNECTION_STRING'
    # optional database name,defaults to `deepstream`
    database: 'DATABASE_NAME'
    # optional table name for records without a splitChar
    # defaults to deepstream_docs
    defaultCollection: 'COLLECTION_NAME'

    # optional character that's used as part of the
    # record names to split it into a table and an id part
    splitChar: '/'