无法连接 Mongodb Atlas 端口

Not able to connect on Mongodb Atlas port

我正在使用 M0 GCP 实例。

我可以使用这个字符串连接到集群:

'mongodb+srv://my_user:my_pass@my_cluster-mbsnz.gcp.mongodb.net/db?retryWrites=true&w=majority'

我正在尝试使用另一个需要传递主机和端口的客户端,但我无法连接。

我尝试通过 telnet 连接到端口 27017,但由于某些原因我无法直接连接到该端口。

curl http://my_cluster-mbsnz.gcp.mongodb.net:27017
curl: (7) Failed to connect to my_cluster-mbsnz.gcp.mongodb.net port 27017: Connection timed out

telnet my_cluster-mbsnz.gcp.mongodb.net 27017
Trying 185.82.212.199...
^C -> After a long time waiting

可能出了什么问题?

+srv 网址使用 DNS 种子。在 atlas 上,您可以单击进入集群,您应该能够看到您的主要和次要的 url,并使用这些 url 进行连接。您还应该能够使用 nslookup 使用该连接字符串的一部分来获取该信息,但是通过 UI.

查找网址可能更简单

https://docs.mongodb.com/manual/reference/connection-string/

In order to leverage the DNS seedlist, use a connection string prefix of mongodb+srv: rather than the standard mongodb:. The +srv indicates to the client that the hostname that follows corresponds to a DNS SRV record. The driver or mongo shell will then query the DNS for the record to determine which hosts are running the mongod instances.