Connecting to a Mongo Cloud database using Go can sometimes present challenges, particularly when transitioning between operating systems. This error encountered on Ubuntu, "error parsing uri...cannot unmarshal DNS message," is not directly related to the MongoDB Go driver but rather stems from a specific behavior in Go version 1.11.x.
The error arises due to a tightening of SRV record handling in Go version 1.11.x, specifically in the net.lookupSRV() function. This results in the rejection of compressed domain names in SRV records, as defined by RFC-2782. Some DNS servers, such as the embedded Docker DNS, may return SRV records with compressed domain names, leading to the error message.
To resolve this issue, you have two options:
For further information, refer to the MongoDB Go driver issue, GODRIVER-829.
The above is the detailed content of Why Does My Go Application Fail to Connect to Mongo Cloud on Ubuntu with a \'cannot unmarshal DNS message\' Error?. For more information, please follow other related articles on the PHP Chinese website!