简体   繁体   English

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

[英]Cannot connect to DeepStream Node.js server if using any custom plugins

So, if I use my DeepStream server as the following所以,如果我使用我的 DeepStream 服务器如下

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

const server = new Deepstream({

server.start()

it's working just fine I can connect to it from my frontend app like the following它工作正常我可以从我的前端应用程序连接到它,如下所示

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

but If I add MongoDB storage instance or RethinkDB NPM - RethinkDB但是如果我添加 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()

I get the following error message when trying to reach my ds server.尝试访问我的 ds 服务器时收到以下错误消息。 (I've also tried to connect via WSS:// instead of WS://) (我也尝试通过 WSS:// 而不是 WS:// 进行连接) 在此处输入图片说明

So hi everybody who has the same problem as me... I figured it out!所以大家好,和我有同样的问题......我想通了! So first of all what the npm packages documentation says from the usage of the Mongo DB driver is completely out of data所以首先,npm 包文档从Mongo DB驱动程序的使用中说的是完全没有数据

so what they say how should u use the npm package :所以他们说你应该如何使用 npm 包:

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();

INSTEAD OF ALL THIS!而不是这一切!

You ain't really need the 'deep stream.io-storage-MongoDB' because it's an old module (based on:您并不是真的需要'deep stream.io-storage-MongoDB'因为它是一个旧模块(基于: 在此处输入图片说明 ), and u don't really need to use this way... ),而且你真的不需要使用这种方式......

The correct usage of the MongoDB connector : MongoDB 连接器的正确用法:

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

server.start();

or you can also create a config.或者你也可以创建一个配置。 yaml file from all this : yaml 文件来自所有这些:

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: '/'

and pass it to the deep stream constructor as below:并将其传递给深流构造函数,如下所示:

const {Deepstream} = require('@deepstream/server');
const server = new Deepstream('config.yaml');

server.start();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM