All nameservers failed to answer UDP port 53 Google cloud functions python 3.7 atlas mongodb

只愿长相守 提交于 2021-02-04 16:25:10

问题


i can connect locally to my mongodb server with the address 0.0.0.0/0. However, when I deploy my code to the cloud I get the error deploy to google cloud function.

google cloud function with python 3.7 (beta) atlas mongo db python lib: -pymongo -dnspython

Error: function crashed. Details: All nameservers failed to answer the query _mongodb._tcp.**-***.gcp.mongodb.net. IN SRV: Server ***.***.***.*** UDP port 53 answered SERVFAIL

Traceback (most recent call last): File "/env/local/lib/python3.7/site-packages/pymongo/uri_parser.py", line 287, in _get_dns_srv_hosts results = resolver.query('_mongodb._tcp.' + hostname, 'SRV') File "/env/local/lib/python3.7/site-packages/dns/resolver.py", line 1132, in query raise_on_no_answer, source_port) File "/env/local/lib/python3.7/site-packages/dns/resolver.py", line 947, in query raise NoNameservers(request=request, errors=errors) dns.resolver.NoNameservers: All nameservers failed to answer the query _mongodb._tcp.**mymongodb**-r091o.gcp.mongodb.net. IN SRV: Server ***.***.***.*** UDP port 53


回答1:


finally after stuck 2 day, goblok banget semaleman

just change connection from

SRV connection string (3.6+ driver)

to

Standard connection string (3.4+ driver)

mongodb://<USERNAME>:<PASSWORD>@<DATABASE>-shard-00-00-r091o.gcp.mongodb.net:27017,<COLLECTION>-shard-00-01-r091o.gcp.mongodb.net:27017,<COLLECTION>-shard-00-02-r091o.gcp.mongodb.net:27017/test?ssl=true&replicaSet=<COLLECTION>-shard-0&authSource=admin&retryWrites=true

or you can see your connection string in atlas mongodb.

idk why can`t connect with srv connection string in google cloud functions, maybe not suppot now, or just misconfiguration.



来源:https://stackoverflow.com/questions/53576199/all-nameservers-failed-to-answer-udp-port-53-google-cloud-functions-python-3-7-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!