Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bolt URI in Neo4j 3.1.0 raises "SocketError: Connection refused" #605

Closed
dhimmel opened this issue Jan 25, 2017 · 1 comment
Closed

Bolt URI in Neo4j 3.1.0 raises "SocketError: Connection refused" #605

dhimmel opened this issue Jan 25, 2017 · 1 comment

Comments

@dhimmel
Copy link

dhimmel commented Jan 25, 2017

While diagnosing another issue, @veleritas and I stumbled upon an odd behavior in py2neo 3.1.2. In this bug report, we'll try to connect to neo4j.het.io (which is currently running Neo4j 3.1.0) using bolt:

import py2neo
assert py2neo.__version__ == '3.1.2'
py2neo.Graph('bolt://neo4j.het.io:7687')

We receive the following error:

Traceback (most recent call last):
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/database/__init__.py", line 318, in __new__
    inst = cls.__instances[key]
KeyError: (<class 'py2neo.database.Graph'>, <ServerAddress settings={'host': 'neo4j.het.io', 'bolt_port': 7687}>, 'data')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/packages/httpstream/http.py", line 322, in submit
    response = send()
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/packages/httpstream/http.py", line 317, in send
    http.request(xstr(method), xstr(uri.absolute_path_reference), body, headers)
  File "/Users/dhimmels/anaconda3/lib/python3.4/http/client.py", line 1137, in request
    self._send_request(method, url, body, headers)
  File "/Users/dhimmels/anaconda3/lib/python3.4/http/client.py", line 1182, in _send_request
    self.endheaders(body)
  File "/Users/dhimmels/anaconda3/lib/python3.4/http/client.py", line 1133, in endheaders
    self._send_output(message_body)
  File "/Users/dhimmels/anaconda3/lib/python3.4/http/client.py", line 963, in _send_output
    self.send(msg)
  File "/Users/dhimmels/anaconda3/lib/python3.4/http/client.py", line 898, in send
    self.connect()
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/packages/httpstream/http.py", line 80, in connect
    self.source_address)
  File "/Users/dhimmels/anaconda3/lib/python3.4/socket.py", line 516, in create_connection
    raise err
  File "/Users/dhimmels/anaconda3/lib/python3.4/socket.py", line 507, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/database/__init__.py", line 327, in __new__
    use_bolt = version_tuple(inst.__remote__.get().content["neo4j_version"]) >= (3,)
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/database/http.py", line 154, in get
    response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/packages/httpstream/http.py", line 966, in get
    return self.__get_or_head("GET", if_modified_since, headers, redirect_limit, **kwargs)
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/packages/httpstream/http.py", line 943, in __get_or_head
    return rq.submit(redirect_limit=redirect_limit, **kwargs)
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/packages/httpstream/http.py", line 433, in submit
    http, rs = submit(self.method, uri, self.body, self.headers)
  File "/Users/dhimmels/anaconda3/lib/python3.4/site-packages/py2neo/packages/httpstream/http.py", line 362, in submit
    raise SocketError(code, description, host_port=uri.host_port)
py2neo.packages.httpstream.http.SocketError: Connection refused

However, the following works:

py2neo.Graph('bolt://neo4j.het.io:7687', bolt=True)

So shouldn't bolt=True be inferred given that the URI begins with bolt://?

@veleritas
Copy link

Connecting to a localhost neo4j 3.1.1 instance with the uri of py2neo.Graph("bolt://localhost:7678/db/data", bolt=True) doesn't work for me, but it works if I instead do py2neo.Graph("localhost:7678/db/data", bolt=True)

With py2neo 3.1.2, the error I get is:

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/session.py", line 124, in session
    session = self.session_pool.pop()
IndexError: pop from an empty deque

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 419, in connect
    s = create_connection(host_port)
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/socket.py", line 711, in create_connection
    raise err
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/socket.py", line 702, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "neo4j-import.py", line 122, in <module>
    main()
  File "neo4j-import.py", line 116, in main
    hetnet_to_neo4j(path, neo4j_dir, port_0)
  File "neo4j-import.py", line 82, in hetnet_to_neo4j
    hetio.neo4j.export_neo4j(graph, uri, 1000, 250, show_progress=True)
  File "/home/ubuntu/hetio/hetio/neo4j.py", line 41, in export_neo4j
    db_graph.delete_all()
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/database/__init__.py", line 453, in delete_all
    self.run("MATCH (a) DETACH DELETE a")
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/database/__init__.py", line 731, in run
    return self.begin(autocommit=True).run(statement, parameters, **kwparameters)
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/database/__init__.py", line 370, in begin
    return self.transaction_class(self, autocommit)
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/database/__init__.py", line 1249, in __init__
    self.session = driver.session()
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/session.py", line 126, in session
    connection = connect(self.address, self.ssl_context, **self.config)
  File "/home/ubuntu/anaconda3/envs/integrate/lib/python3.5/site-packages/py2neo/packages/neo4j/v1/bolt.py", line 422, in connect
    raise ProtocolError("Unable to connect to %s on port %d - is the server running?" % host_port)
py2neo.packages.neo4j.v1.exceptions.ProtocolError: Unable to connect to localhost on port 7678 - is the server running?

esmono referenced this issue in esmono/flask-neo4j Jul 27, 2017
…echnige/py2neo/issues/605 . It must work on py2neo v2 because it will not call anything else. And in py2neo v3 will add the parameter when the port is used in the connection string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants