Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2031

Fail when SRV URI is given as a host to Client constructor

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.13.0.rc1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Fully Compatible

      Currently the URI is mangled into a port number silently as follows:

      irb(main):001:0> client = Mongo::Client.new(
      irb(main):002:1*   ['mongodb+srv://<cluster-url>/test'],
      irb(main):003:1*   auth_mech: :mongodb_x509,
      irb(main):004:1*   ssl: true,
      irb(main):005:1*   ssl_cert: '/etc/certs/mongodb/client.pem',
      irb(main):006:1*   ssl_key: '/etc/certs/mongodb/client.pem'
      irb(main):007:1> )
      D, [2019-11-27T13:33:50.456234 #8495] DEBUG -- : MONGODB | EVENT: #<TopologyOpening topology=Unknown[]>
      D, [2019-11-27T13:33:50.456413 #8495] DEBUG -- : MONGODB | Topology type 'unknown' initializing.
      D, [2019-11-27T13:33:50.456872 #8495] DEBUG -- : MONGODB | EVENT: #<TopologyChanged prev=Unknown[] new=Unknown[mongodb+srv:0]>
      D, [2019-11-27T13:33:50.457012 #8495] DEBUG -- : MONGODB | Topology type 'Unknown' changed to type 'Unknown'.
      D, [2019-11-27T13:33:50.457383 #8495] DEBUG -- : MONGODB | EVENT: #<ServerOpening address=mongodb+srv:0 topology=Unknown[mongodb+srv:0]>
      D, [2019-11-27T13:33:50.457490 #8495] DEBUG -- : MONGODB | Server mongodb+srv:0 initializing.
      D, [2019-11-27T13:33:50.457872 #8495] DEBUG -- : MONGODB | Waiting for up to 30.00 seconds for servers to be scanned: #<Cluster topology=Unknown[mongodb+srv:0] servers=[#<Server address=mongodb+srv:0 UNKNOWN>]>
      D, [2019-11-27T13:33:50.459514 #8495] DEBUG -- : MONGODB | Error running ismaster on mongodb+srv:0: SocketError: getaddrinfo: Name or service not known
      => #<Mongo::Client:0x47136704077700 cluster=#<Cluster topology=Unknown[mongodb+srv:0] servers=[#<Server address=mongodb+srv:0 UNKNOWN>]>>

      Ref: https://github.com/mongodb/docs-ecosystem/pull/585

      Suggested implementation: if any of the hosts given to the Client constructor start with mongodb+srv://, raise an error.

            neil.shweky@mongodb.com Neil Shweky (Inactive)
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            0 Vote for this issue
            2 Start watching this issue