nicolewhite / cycli

A Command Line Interface for Neo4j's Cypher.
MIT License
272 stars 25 forks source link

Not able to connect with database with non-standard bolt port and TLS #51

Open Judit opened 7 years ago

Judit commented 7 years ago

I'm having troubles connecting with a database hosted in GrapheneDB using cycli 0.7.6. I'm only able to connect databases with Neo4j version < 3.

If I try the same parameters that I used to connect with a database >= 3, I get the following:

$cycli -u USERNAME -p PASS -h hobby-fdaalmhijildgbkemjfeffnl.dbs.graphenedb.com -P 24789

Cycli version: 0.7.6
Neo4j version: 3.0.6
Bug reports: https://github.com/nicolewhite/cycli/issues

> MATCH (n) RETURN count(n);
[Errno 110] Connection timed out

I think passing bolt=None to py2neo makes it try to connect via Bolt. The database version is >= 3, but GrapheneDB uses a non-standard port for Bolt connections and also needs to use TLS secure connections. I managed to connect to my database using py2neo with the following options:

Graph("bolt://hobby-fdaalmhijildgbkemjfeffnl.dbs.graphenedb.com:24786", user=USERNAME, password=PASS, bolt=True, secure = True, http_port = 24789)

It would be great if you can add more options to be able to use your tool for GrapheneDB (at least: bolt, bolt_port). Currently, with databases >= 3 is not possible to connect with neither HTTP/HTTPS, nor Bolt protocol.

nicolewhite commented 7 years ago

Have you tried passing the --ssl flag?

albertoperdomo commented 7 years ago

Hello @nicolewhite, the issue still persists using the --ssl flag. Here are some examples of connection issues against Neo4j 3.1.4:

Cycli version:

$ cycli -v
cycli 0.7.6

Passing the port number for Bolt and the ssl flag:

$ cycli -h db-ba7d0ffd9ejjgigs7w22.graphenedb.com -P 24786 -u testuser -p b.RM3HBvS5UQK6.aNjGi2ejfw2NOfgp --ssl
Traceback (most recent call last):
  File "/usr/local/bin/cycli", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/cycli/main.py", line 275, in run
    cycli = Cycli(host, port, username, password, logfile, filename, ssl, read_only, timeout)
  File "/usr/local/lib/python2.7/site-packages/cycli/main.py", line 37, in __init__
    self.neo4j = Neo4j(host, port, username, password, ssl, timeout)
  File "/usr/local/lib/python2.7/site-packages/cycli/driver.py", line 50, in __init__
    self.graph = Graph(uri, user=username, password=password, bolt=bolt, secure=ssl)
  File "/usr/local/lib/python2.7/site-packages/py2neo/database/__init__.py", line 327, in __new__
    use_bolt = version_tuple(inst.__remote__.get().content["neo4j_version"]) >= (3,)
TypeError: string indices must be integers, not str

Passing the port number for HTTPS and the ssl flag:

$ cycli -h db-ba7d0ffd9ejjgigs7w22.graphenedb.com -P 24780 -u testuser -p b.RM3HBvS5UQK6.aNjGi2ejfw2NOfgp --ssl
Traceback (most recent call last):
  File "/usr/local/bin/cycli", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/cycli/main.py", line 275, in run
    cycli = Cycli(host, port, username, password, logfile, filename, ssl, read_only, timeout)
  File "/usr/local/lib/python2.7/site-packages/cycli/main.py", line 37, in __init__
    self.neo4j = Neo4j(host, port, username, password, ssl, timeout)
  File "/usr/local/lib/python2.7/site-packages/cycli/driver.py", line 50, in __init__
    self.graph = Graph(uri, user=username, password=password, bolt=bolt, secure=ssl)
  File "/usr/local/lib/python2.7/site-packages/py2neo/database/__init__.py", line 327, in __new__
    use_bolt = version_tuple(inst.__remote__.get().content["neo4j_version"]) >= (3,)
  File "/usr/local/lib/python2.7/site-packages/py2neo/database/http.py", line 157, in get
    raise Unauthorized(self.uri.string)
py2neo.database.status.Unauthorized: https://db-ba7d0ffd9ejjgigs7w22.graphenedb.com:24780/db/data/

Note: this database has been deleted any further connection attempt using this set or another set of credentials will fail.

JochemKuijpers commented 6 years ago

I'm facing the same problem; my setup has HTTP at :8080 and BOLT at :8081. I cannot use the default ports.

$ cycli --host example.com -P 8080 -u user -p password
 ______     __  __     ______     __         __    
/\  ___\   /\ \_\ \   /\  ___\   /\ \       /\ \   
\ \ \____  \ \____ \  \ \ \____  \ \ \____  \ \ \  
 \ \_____\  \/\_____\  \ \_____\  \ \_____\  \ \_\ 
  \/_____/   \/_____/   \/_____/   \/_____/   \/_/ 
Cycli version: 0.7.6
Neo4j version: 3.4.0
Bug reports: https://github.com/nicolewhite/cycli/issues

> MATCH (:USER) RETURN COUNT(*);
[Errno 110] Connection timed out

It appears cycli is able to get some information from the database though, since autocomplete works and schema output is correct.