Elasticsearch-py: Switching on sniff mode triggers ValueError

Created on 17 Feb 2016  路  3Comments  路  Source: elastic/elasticsearch-py

I think there is a bug in the latest version. It related to not being able to parse response properly from Elasticsearch when sniffing?

If you enable Sniff mode, then you get the following error. There is an "]" bracket on the value that comes with the port string (probably from), and when the library tries to do an int("9200]"), it gives a ValueError and crashes. Details below:

ValueError: invalid literal for int() with base 10: '9200]'
Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 150, in __init__ self.transport = transport_class(_normalize_hosts(hosts), **kwargs) File "/usr/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 126, in __init__ self.sniff_hosts(True) File "/usr/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 250, in sniff_hosts host['port'] = int(port) ValueError: invalid literal for int() with base 10: '9200]'

Most helpful comment

The 2.x version of the library is only compatible with 2.x server versions, this isn't expected to work.

All 3 comments

To give more details, the sniff result from Elasticsearch on my Elasticsearch is as follows (its Elasticsearch inside a Docker container)

{
"cluster_name": "mycluster",
"nodes": {
"wsOfrxfBQEC5kU1aL_Hmlw": {
"name": "Crown",
"transport_address": "inet[/192.168.1.5:9300]",
"host": "elasticsearch",
"ip": "172.17.0.9",
"version": "1.6.2",
"build": "6220391",
"http_address": "inet[/192.168.1.5:9200]"
}
}
}

So I think the bug is in the part where one tries to split the host using a ":", but there is a trailing "]"

Looks like this could be because I was using 2.x library on 1.6 server. Sniffing is not compatible.

If its not important to add compatibility, then this can be closed.

The 2.x version of the library is only compatible with 2.x server versions, this isn't expected to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edemauro picture edemauro  路  4Comments

tlinhart picture tlinhart  路  5Comments

staticdev picture staticdev  路  3Comments

tirkarthi picture tirkarthi  路  6Comments

K-7 picture K-7  路  6Comments