python urllib3 awsElasticSearch连接错误

w1e3prcc  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(0)|浏览(794)

我编写了一个python脚本,它使用elasticsearch库连接到aws elasticsearch集群。有一段时间一切正常,但突然抛出connectionerror(<urllib3.connection.httpsconnection object at 0x7fec57c238e0>:无法建立新连接:[errno-2]名称或服务未知),原因是:newconnectionerror(<urllib3.connection.httpsconnection object at 0x7fec57c238e0>:无法建立新连接:[errno-2]名称或服务(未知)。
当我重新启动服务器时,错误消失了,但过了一段时间又回来了。有人能帮我解决这个问题吗?
发布日志以供参考:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.8/dist-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.8/socket.py", line 918, 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.8/dist-packages/elasticsearch/connection/http_urllib3.py", line 245, in perform_request
    response = self.pool.urlopen(
  File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/dist-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/dist-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.8/dist-packages/urllib3/connection.py", line 309, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.8/dist-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fec57c238e0>: Failed to establish a new connection: [Errno -2] Name or service not known

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题