Connection to neo4j gatadatascience sandbox is failing

i have a auradb sandbox for Graph data science.

i have a python notebook. it has two cells. one cells connects , the other one doesn't.

the sandbox is opennow. the password i put in below is real. you can test it yourself.

The first cell is using GraphDabase.driver and it connects ok.

from neo4j import GraphDatabase

Neo4j connection details

NEO4J_URI = 'bolt://3.95.137.38:7687'
NEO4J_USERNAME = 'neo4j'
NEO4J_PASSWORD = 'laundries-battery-cabs'

def test_connection(uri, username, password):
try:
driver = GraphDatabase.driver(uri, auth=(username, password))
print("Driver created successfully.")
session = driver.session()
result = session.run("RETURN 'Connection Successful' AS message")
print(f"Connection successful: {result.single()['message']}")
session.close()
except Exception as e:
print(f"Connection failed: {e}")

test_connection(NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD)

but the other cell fails

from graphdatascience import GraphDataScience
import graphdatascience

#from neo4j import GraphDatabase

NEO4J_URI = 'neo4j+s://5618a8fbafb4015155a4e6793dc9fb18.bolt.neo4jsandbox.com:443'

NEO4J_USERNAME = 'neo4j'
NEO4J_PASSWORD = 'laundries-battery-cabs'
AURA_DS = True

try:
gds = GraphDataScience(
NEO4J_URI,
auth=(NEO4J_USERNAME, NEO4J_PASSWORD),
aura_ds=AURA_DS
)
print ("connected successfuly")
gds.set_database("neo4j") # Ensure the database exists; remove this if it's not needed.
print(f"Connected to GDS version: {gds.version()}")
except Exception as e:
print(f"Failed to connect to GDS: {e}")

the neo4j+s link i put there is the same one that i can login to neo4j browser

ip address: 3.95.137.38
htp port 7474
bolt port 7687

Bolt URL:

bolt://3.95.137.38:7687

Websocket Bolt URL:

bolt+s://5618a8fbafb4015155a4e6793dc9fb18.neo4jsandbox.com:7687

Websocket Bolt URL (Port 443):

bolt+s://5618a8fbafb4015155a4e6793dc9fb18.bolt.neo4jsandbox.com:443

it seems GraphDataScience needs neo4j+s connection . that is reason i put there but still is failing.

i appreciate your help

Hi.

I have a few questions to be better able to help you:

  • what's the error you're seeing?
  • Why are the two cells using different URLs (one uses an IP address, the other uses some neo4jsandbox.com domain name)? Are they supposed to be the same server?
  • Try not mixing the URL schemes (the thing that ends in :// at the beginning of the URL) when comparing connectivity. Since the GDS client is using the driver underneath the hood, if one library can connect with a given URL, you can assume that the other will be able to connect as well.
  • Could you please edit the question and use code blocks to format the cells so that the code is readable and actually executable (since Python is witespace sensitive, this matters for more than just style)?

This is my python code

it returns Unable to retrieve routing information

the username/password are real

from sandox, i can open the browser and it connects through the same neo4j+s i url in below but the python is not working

from graphdatascience import GraphDataScience
import graphdatascience

#from neo4j import GraphDatabase

#NEO4J_URI = 'bolt://3.95.137.38:7687'
NEO4J_URI = 'neo4j+s://5618a8fbafb4015155a4e6793dc9fb18.bolt.neo4jsandbox.com:443'

NEO4J_USERNAME = 'neo4j'
NEO4J_PASSWORD = 'laundries-battery-cabs'
AURA_DS = True
try:
gds = GraphDataScience(
NEO4J_URI,
auth=(NEO4J_USERNAME, NEO4J_PASSWORD),
aura_ds=AURA_DS
)
print ("connected successfuly")
gds.set_database("neo4j") # Ensure the database exists; remove this if it's not needed.
print(f"Connected to GDS version: {gds.version()}")
except Exception as e:
print(f"Failed to connect to GDS: {e}")

Hi Rouven

I appreciate your help regarding this