from elasticsearch import Elasticsearch
es = Elasticsearch([{'host': '192.168.7.101', 'port': 9200}])
es
res = es.search(index='opm', body = {"query": {"match": {"event_country_name":"Singapore"}}}, request_timeout=30)
上面的代码给出以下错误:
ConnectionError:ConnectionError(:无法建立新的连接: [WinError 10060]连接尝试失败,因为已连接 一段时间后未正确响应,或已建立 连接失败,因为已连接的主机无法响应) 作者:NewConnectionError(:无法建立新连接:[WinError 10060]连接尝试失败,因为被连接方未 一段时间后正确响应或建立连接 失败,因为连接的主机无法响应)
它正在工作。我不知道发生了什么,现在无法访问。我试图更新点子。然后我降级以查看问题是否与此有关。没啥事儿。我什至尝试卸载并重新安装python和urllib3。
请帮帮我。
完整的错误消息是:
GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.017s]
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
raise err
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
raise six.reraise(type(error), error, _stacktrace)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
raise value
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
self.connect()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
conn = self._new_conn()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000021CBDA8FF28>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.020s]
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
raise err
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
raise six.reraise(type(error), error, _stacktrace)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
raise value
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
self.connect()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
conn = self._new_conn()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000021CBDA8FF98>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.016s]
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
raise err
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
raise six.reraise(type(error), error, _stacktrace)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
raise value
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
self.connect()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
conn = self._new_conn()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000021CBDAB20B8>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.022s]
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
raise err
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
raise six.reraise(type(error), error, _stacktrace)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
raise value
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
self.connect()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
conn = self._new_conn()
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000021CBDAB2160>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Traceback (most recent call last):
File "<ipython-input-7-37571f0445fd>", line 1, in <module>
res = es.search(index='opm', body = {"query": {"match": {"event_country_name":"Singapore"}}}, request_timeout=30)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\client\utils.py", line 76, in _wrapped
return func(*args, params=params, **kwargs)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\client\__init__.py", line 660, in search
doc_type, '_search'), params=params, body=body)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\transport.py", line 318, in perform_request
status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 181, in perform_request
raise ConnectionError('N/A', str(e), e)
ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x0000021CBDAB2160>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x0000021CBDAB2160>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)
答案 0 :(得分:0)
大多数时候,这种错误是由于代理设置引起的。如果您使用代理客户端,请确保其启动并运行。
答案 1 :(得分:0)
您尝试过的是客户端(python连接到Elastic Search服务器),但是阅读该消息似乎似乎是Elastic Search服务器本身存在问题。它看起来并不像编程问题。如果您可以访问Elastic Search服务器,请确保它正在运行。如果它在同一台机器上运行,请确保机器ip仍然相同(DHCP更新可以更改地址)。还要检查您的网络连接是否正常。