1

I have written the code to import json to elasticsearch, but I have got Connection Error as 'Connection aborted.', error(104, 'Connection reset by peer'

The code is

from pyelasticsearch import ElasticSearch
import sys, json

ES_CLUSTER = 'http://localhost:9200/'
ES_INDEX = 'test'
ES_TYPE = 'doc'
es = ElasticSearch(ES_CLUSTER)

json_docs = []
with open(r'sample_data.json') as open_file:
        data = json.load(open_file)
        for js in data:
                json_docs.append(js)

es.bulk(ES_INDEX, ES_TYPE, json_docs)

The error is

Traceback (most recent call last):
  File "el_ex.py", line 18, in <module>
    es.bulk(ES_INDEX, ES_TYPE, json_docs) 
  File "/home/tradevigil123/.local/lib/python2.7/site-packages/pyelasticsearch/client.py", line 93, in decorate
    return func(*args, query_params=query_params, **kwargs)
  File "/home/tradevigil123/.local/lib/python2.7/site-packages/pyelasticsearch/client.py", line 448, in bulk
    query_params=query_params)
  File "/home/tradevigil123/.local/lib/python2.7/site-packages/pyelasticsearch/client.py", line 281, in send_request
    raise exc.info
urllib3.exceptions.ProtocolError: ('Connection aborted.', error(104, 'Connection reset by peer'))

Can, anyone help me out ?

1 Answers1

0

this error message usually means that the other side has closed the connection. This shouldnt happen by Elasticsearch, except for bad problems like a garbage collection or the process dying. Have you checked the Elasticsearch logs? Can you connect to Elasticsearch after that? How big is your bulk request? Have you tried something like 10MB for bulk size?

alr
  • 1,744
  • 1
  • 10
  • 11