Code Monkey home page Code Monkey logo

Comments (11)

lchben avatar lchben commented on May 27, 2024

image

from emqx.

zmstone avatar zmstone commented on May 27, 2024

请问可以提供一下mongo的具体部署方式吗?我们来复现一下。

from emqx.

zmstone avatar zmstone commented on May 27, 2024

OK. The automatic version detection does not work quite well with MongoDB v4.
You can however set this flag to make it work:
image

from emqx.

lchben avatar lchben commented on May 27, 2024

还行。自动版本检测在 MongoDB v4 中效果不佳。但是,您可以设置此标志以使其正常工作: 图像

@zmstone 我需要如何找到此设置?我使用5.6.1 (Open Source)版本。但是操作界面没有这项设置。另外如果mongodb不开启秘钥认证,EMQX是可以正常链接的。mongodb4.0开启秘钥认证才出现的上述现象。
image

from emqx.

zmstone avatar zmstone commented on May 27, 2024

抱歉,认证配置中可能没有包含这个选项。我们会在后续版本中加上
可以试一下这个命令:
emqx eval application:set_env(mongodb,use_legacy_protocol,true).

from emqx.

nikosheng avatar nikosheng commented on May 27, 2024

Hi @zmstone 我成功設置了這個指令後, 是否這個指令直接應用到所有目前的 mongo authentication?

from emqx.

zmstone avatar zmstone commented on May 27, 2024

@nikosheng 是的。

from emqx.

nikosheng avatar nikosheng commented on May 27, 2024

Hi @zmstone , 我嘗試了一下, 發現通過emqx ctl 或者修改 config 文件都是不行, 如下是我的 emqx.conf

node {
  name = "[email protected]"
  cookie = "emqxsecretcookie"
  data_dir = "/var/lib/emqx"
}

cluster {
  name = emqxcl
  discovery_strategy = manual
}

mongodb {
  use_legacy_protocol = "true"
}

請問我可以在哪裏可以看到這個 config 已經應用到 emqx 的運行時?

from emqx.

zmstone avatar zmstone commented on May 27, 2024

mongodb不能这样配置。

可以这样: 在集群中所有节点都修改: data/config/cluster.hocon 然后重启

authentication = [
  {
    backend = mongodb
    collection = users
    database = mqtt
    filter {
      username = "${username}"
    }
    mechanism = password_based
    mongo_type = single
    password_hash_algorithm {name = sha256, salt_position = suffix}
    password_hash_field = password_hash
    pool_size = 8
    salt_field = salt
    server = "127.0.0.1:27017"
    srv_record = false
    ssl {enable = false, verify = verify_peer}
    topology {
      connect_timeout_ms = "20s"
    }
    use_legacy_protocol = true # <================ 把这行加上
  }
]

from emqx.

nikosheng avatar nikosheng commented on May 27, 2024

Thanks @zmstone

However, I still cannot connect to my mongo v4 after I configure use_legacy_protocol to true (after emqx restart).

My mongo version is

Using MongoDB:		4.2.14

Here is the error log

2024-05-24T02:19:43.218437+00:00 [warning] msg: start_resource_failed, id: <<"emqx_authn_mongodb:1">>, reason: {start_pool_failed,<<"emqx_authn_mongodb:1">>,{connect_failed,{saslStart,#{<<"code">> => 18,<<"codeName">> => <<"AuthenticationFailed">>,<<"errmsg">> => <<"Authentication failed.">>}}}}

Here is my cluster.hocon

authentication = [
  {
    backend = mongodb
    collection = users
    database = mqtt
    enable = true
    filter {
      username = "${username}"
    }
    is_superuser_field = is_superuser
    mechanism = password_based
    mongo_type = single
    password = xxx
    password_hash_algorithm {name = sha256, salt_position = suffix}
    password_hash_field = password_hash
    pool_size = 8
    salt_field = salt
    server = "127.0.0.1:27019"
    srv_record = false
    ssl {
      ciphers = []
      depth = 10
      enable = false
      hibernate_after = 5s
      log_level = notice
      reuse_sessions = true
      secure_renegotiate = true
      verify = verify_none
      versions = [tlsv1.3, tlsv1.2]
    }
    topology {
      connect_timeout_ms = 20s
      heartbeat_frequency_ms = 200s
      max_overflow = 0
    }
    use_legacy_protocol = true
    username = eqmx
  }
]

from emqx.

nikosheng avatar nikosheng commented on May 27, 2024

Besides, I assume that the original setting auto can help to decide whether to use the latest mongo api.

use_legacy_protocol

Type Enum(auto,true,false)
Default auto
Description Whether to use MongoDB's legacy protocol for communicating with the database. The default is to attempt to automatically determine if the newer protocol is supported.

from emqx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.