MongoDB Atlas连接错误-UnicodeError:标签太长,UnicodeError:使用“ idna”编解码器的编码失败(UnicodeError:标签太长)

时间:2018-08-13 15:32:42

标签: mongodb atlas

我正在尝试连接到刚刚设置的MongoDB集群。但是,我遇到了这些错误,但无法找到解决方案。帮助将不胜感激!

Python3

Mongodb Altas群集-连接:

atlasstring = urllib.parse.quote(
"mongodb://<<MYEMAIL>>:<<MYPASSWORD>>@test-shard-00-00-3sqgv.mongodb.net:27017,test-shard-00-01-3sqgv.mongodb.net:27017,test-shard-00-02-3sqgv.mongodb.net:27017/test?ssl=true&replicaSet=test-shard-0&authSource=admin&retryWrites=true")

代码:

从pymongo导入MongoClient     从atlasclusterpassword导入atlasstring

client = MongoClient(atlasstring)

db = client.azuresupport

print(client.mflix)

错误:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/pool.py", line 357, in get_socket
    sock_info, from_pool = self.sockets.pop(), True
KeyError: 'pop from an empty set'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/idna.py", line 167, in encode
    raise UnicodeError("label too long")
UnicodeError: label too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bethwalsh/Documents/classification-twitter-app/test/test-mongo.py", line 6, in <module>
    client = MongoClient(atlasstring)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/mongo_client.py", line 374, in __init__
    self._ensure_connected(True)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/mongo_client.py", line 939, in _ensure_connected
    self.__ensure_member()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/mongo_client.py", line 813, in __ensure_member
    member, nodes = self.__find_node()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/mongo_client.py", line 873, in __find_node
    member, nodes = self.__try_node(candidate)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/mongo_client.py", line 716, in __try_node
    sock_info = connection_pool.get_socket()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/pool.py", line 361, in get_socket
    sock_info, from_pool = self.connect(), False
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/pool.py", line 288, in connect
    sock = self.create_connection()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pymongo/pool.py", line 258, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label too long)
[Finished in 0.141s]

0 个答案:

没有答案