1

so I have an elasticsearch instance running locally:

elasticsearch
OpenJDK 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory
...starting 
...
[2019-07-18T12:45:46,137][INFO ][o.e.t.TransportService   ] [H1YDvcg] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2019-07-18T12:45:49,182][INFO ][o.e.c.s.MasterService    ] [H1YDvcg] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {H1YDvcg}{H1YDvcgbTMSnTmVdTNQo7A}{9j3_6Y8LTg2KaImHpCQvaw}{127.0.0.1}{127.0.0.1:9300}
[2019-07-18T12:45:49,186][INFO ][o.e.c.s.ClusterApplierService] [H1YDvcg] new_master {H1YDvcg}{H1YDvcgbTMSnTmVdTNQo7A}{9j3_6Y8LTg2KaImHpCQvaw}{127.0.0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {H1YDvcg}{H1YDvcgbTMSnTmVdTNQo7A}{9j3_6Y8LTg2KaImHpCQvaw}{127.0.0.1}{127.0.0.1:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2019-07-18T12:45:49,198][INFO ][o.e.h.n.Netty4HttpServerTransport] [H1YDvcg] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2019-07-18T12:45:49,199][INFO ][o.e.n.Node               ] [H1YDvcg] started
[2019-07-18T12:45:49,343][INFO ][o.e.g.GatewayService     ] [H1YDvcg] recovered [1] indices into cluster_state
[2019-07-18T12:45:49,511][INFO ][o.e.c.r.a.AllocationService] [H1YDvcg] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[person][2]] ...]).

and I can hit localhost:9200 through my browser.

I am also trying to run a docker container for an application that uses this ES process.

docker run -e ES_HOST=host.docker.internal -e ES_PORT='9200' -e AWS_ACCESS_KEY_ID='<some_key>' -e AWS_SECRET_ACCESS_KEY='<some_key>'             -e AWS_DEFAULT_REGION='us-west-2' <application_name>

and my es client looks like this (python):

import ssl
from elasticsearch import Elasticsearch, RequestsHttpConnection
from elasticsearch.connection import create_ssl_context
from aws_requests_auth.boto_utils import 

# this is temporary to ignore SSL certs while working in the sandbox
ssl_context = create_ssl_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE

# create the client
try:
    _es_host = environ["ES_HOST"]
    _es_port = int(environ["ES_PORT"])
except KeyError:
    logger.error("Environment variables ES_HOST and ES_PORT must be set")
    exit(1)

# see https://github.com/DavidMuller/aws-requests-auth
auth = BotoAWSRequestsAuth(aws_host=_es_host,
                           aws_region="us-west-2",
                           aws_service="es")

es_client = Elasticsearch(host=_es_host,
                          port=_es_port,
                          connection_class=RequestsHttpConnection,
                          scheme="http" if "localhost" in _es_host else "https",
                          use_ssl=False,
                          ssl_context=ssl_context,
                          http_auth=auth)

and I get this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='host.docker.internal', port=9200): Max retries exceeded with url: /person/_search (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1076)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/elasticsearch/connection/http_requests.py", line 76, in perform_request
    response = self.session.send(prepared_request, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='host.docker.internal', port=9200): Max retries exceeded with url: /person/_search (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1076)')))
^CTraceback (most recent call last):
  File "dataloader.py", line 267, in <module>
    receive_messages(assertions_queue, dlq, primary_queue_name.endswith(".fifo"))
  File "dataloader.py", line 133, in receive_messages
    handle_assertion_message(message)
  File "dataloader.py", line 46, in handle_assertion_message
    persons = execute_match_rule(match_rule_clauses)
  File "dataloader.py", line 22, in execute_match_rule
    return search_for_matches(PERSON_INDEX, match_rule_clauses)
  File "dataloader.py", line 232, in search_for_matches

which seems like some kind of ssl error. Anyone have any idea on how to fix this?

I am using host.docker.internal because the es is on my machine's localhost, not my docker container's localhost. That makes sense right?

Jwan622
  • 11,015
  • 21
  • 88
  • 181
  • duplicate https://stackoverflow.com/questions/57080070/not-able-to-connect-to-local-elasticsearch-process-from-docker-container – mchawre Jul 18 '19 at 17:00
  • Possible duplicate of [Not able to connect to local elasticsearch process from docker container](https://stackoverflow.com/questions/57080070/not-able-to-connect-to-local-elasticsearch-process-from-docker-container) – helmbert Jul 18 '19 at 21:36

0 Answers0