Skip to content

Commit

Permalink
GODRIVER-2679 Elaborate on DNS issues docs and confusing DNS error. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
benjirewis authored Jan 11, 2023
1 parent ef0c0ab commit c05cb8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions mongo/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@
//
// # Potential DNS Issues
//
// Building with Go 1.11+ and using connection strings with the "mongodb+srv"[1] scheme is
// Building with Go 1.11+ and using connection strings with the "mongodb+srv"[1] scheme is unfortunately
// incompatible with some DNS servers in the wild due to the change introduced in
// https://github.com/golang/go/issues/10622. If you receive an error with the message "cannot
// unmarshal DNS message" while running an operation, we suggest you use a different DNS server.
// https://github.com/golang/go/issues/10622. You may receive an error with the message "cannot unmarshal DNS message"
// while running an operation when using DNS servers that non-compliantly compress SRV records. Old versions of kube-dns
// and the native DNS resolver (systemd-resolver) on Ubuntu 18.04 are known to be non-compliant in this manner. We suggest
// using a different DNS server (8.8.8.8 is the common default), and, if that's not possible, avoiding the "mongodb+srv"
// scheme.
//
// # Client Side Encryption
//
Expand Down
4 changes: 3 additions & 1 deletion x/mongo/driver/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func (r *Resolver) fetchSeedlistFromSRV(host string, srvName string, stopOnErr b
srvName = "mongodb"
}
_, addresses, err := r.LookupSRV(srvName, "tcp", host)
if err != nil {
if err != nil && strings.Contains(err.Error(), "cannot unmarshal DNS message") {
return nil, fmt.Errorf("see https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#hdr-Potential_DNS_Issues: %w", err)
} else if err != nil {
return nil, err
}

Expand Down

0 comments on commit c05cb8a

Please sign in to comment.