我构建了一个API (带有烧瓶-restful),它将数据存储在缓存中,并将其公开给其他应用程序。当我试图从另一个应用程序(也是烧瓶)向这个API发送get请求时,它会返回以下错误
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 170, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 73, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 706, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 353, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 182, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f6f965d9358>: Failed to establish a new connection: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='data-collector.cloud', port=443): Max retries exceeded with url: /sample_url (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f6f965d9358>: Failed to establish a new connection: [Errno -2] Name or service not known',))我认为发生此错误是因为我向API发送了太多带有相同url的请求。然后,我将decorators = [index.limiter.limit("60/minute")]添加到API中,从而限制了API调用的次数。然而,错误仍然持续存在。然后,我认为错误可能是由服务器接受的调用数量造成的。我以为在调用API之后,我没有正确地关闭连接。所以我加入了
from requests.packages.urllib3 import Retry, PoolManager
retries = Retry(connect=5, read=2, redirect=5)
with PoolManager(retries=retries) as http:
response = http.request('GET', url)但这也解决不了我的问题。我在这里错过了什么?我用的是丙酮3.8
编辑:--我发现导致它的并不是查询本身,因为如果我尝试其他查询,就会弹出相同的消息。我仍然不知道如何调试这个:/
发布于 2021-06-24 10:20:07
错误上写着:“姓名或服务不知道”。换句话说,这是一个名称解析问题(DNS)。
交叉检查目标主机(“数据收集器。云”,它不在公共DNS记录中)。
https://stackoverflow.com/questions/68096077
复制相似问题