https://github.com/mongodb/specifications/blob/master/source/initial-dns-seedlist-discovery/initial-dns-seedlist-discovery.rst#seedlist-discovery requires a minimum of 3 components in a hostname prior to issuing DNS queries. This restriction can be bypassed by giving a trailing dot in the hostname.
# correctly rejected irb(main):002:0> a=Mongo::Client.new('mongodb+srv://hai.xx') Mongo::Error::InvalidURI (Bad URI: mongodb+srv://hai.xx) The domain name must consist of at least two parts: the domain name, and a TLD. MongoDB URI must be in the following format: mongodb+srv://[username:password@]host[/[database][?options]] Please see the following URL for more information: http://docs.mongodb.org/manual/reference/connection-string/
# incorrectly accepted irb(main):004:0> a=Mongo::Client.new('mongodb+srv://hai.xx.') Traceback (most recent call last): 13: from /home/w/.rbenv/versions/2.6.1/bin/irb:23:in `<main>' 12: from /home/w/.rbenv/versions/2.6.1/bin/irb:23:in `load' 11: from /home/w/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>' 10: from (irb):4 9: from (irb):4:in `rescue in irb_binding' 8: from (irb):4:in `new' 7: from /home/w/apps/ruby-driver/lib/mongo/client.rb:324:in `initialize' 6: from /home/w/apps/ruby-driver/lib/mongo/uri.rb:221:in `get' 5: from /home/w/apps/ruby-driver/lib/mongo/uri.rb:221:in `new' 4: from /home/w/apps/ruby-driver/lib/mongo/uri.rb:258:in `initialize' 3: from /home/w/apps/ruby-driver/lib/mongo/uri.rb:315:in `parse!' 2: from /home/w/apps/ruby-driver/lib/mongo/uri/srv_protocol.rb:99:in `parse_creds_hosts!' 1: from /home/w/apps/ruby-driver/lib/mongo/uri/srv_protocol.rb:122:in `get_records' Mongo::Error::NoSRVRecords (The DNS query returned no SRV records at hostname (hai.xx.))
In get_records in srv_protocol.rb, `query_name` for `hai.xx` is computed to be:
(byebug) query_name
"_mongodb._tcp.hai.xx."
The Ruby resolver accepts trailing dots in domain names:
(byebug) resolver.getresources('google.com.', Resolv::DNS::Resource::IN::A)
[#<Resolv::DNS::Resource::IN::A:0x000055be00775010 @address=#<Resolv::IPv4 172.217.7.14>, @ttl=5>]
- is duplicated by
-
RUBY-1750 Two-part hostname requirement error message is confusing
- Closed
- is related to
-
PYTHON-1760 Driver accepts two and one part hostnames in SRV URIs
- Closed
-
DRIVERS-2058 Test two part hostname with trailing dot in initial seed list tests
- Backlog
- links to