How to remotely access an neo4j community container running on azure with python(neo4j module)?

There is a neo4j community version container running on the azure, and i was provided by the dns

http://[remote-address]:7687

if i do curl with proxy(px from github)(office recommended also), i able to get, bolt_routing, transaction, bolt_direct, neo4j_version, neo4j_edition all successfully,

And with 7474 port with web browser i also able to connect to the db and same with neo4j desktop by adding remote db.

but when i do with python neo4j driver, Cannot resolve address [remote-address]:7687

import neo4j,sys
link = "bolt://" + sys.argv[1]
print(f"Trying to connect to:  {link}")

def exp():
    try:
        x = neo4j.GraphDatabase.driver(link, auth=("neo4j", "my_pswd"))

        print(x.verify_connectivity())
    except Exception as e:
        print(e)

so, how to connect to a container hosted on azure ?

Update:

i tried to connect with IP of the azure instance running, but

Couldn't connect to [IP-address]:7687 (resolved to ('[IP-address]:7687',)):

Failed to establish connection to ResolvedIPv4Address(('[IP-address]', 7687)) (reason [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

it is connection through web and neo4j browser completely fine, only not through the python script.!!

2 answers

  • answered 2022-03-18 00:17 jose_bacoy

    I would recommend neo4j Aura. It is a fully managed cloud service and has a hassle free connection to a database. It is also has a free tier to try. See sample script to connect into it:

    https://neo4j.com/cloud/aura/

    import neo4j,sys
    link = "bolt://" + sys.argv[1]
    print(f"Trying to connect to:  {link}")
    #format of uri is <9999>.databases.neo4j.io
    
    def exp():
        try:
            x = neo4j.GraphDatabase.driver(link, auth=("neo4j", "my_pswd"))
    
            print(x.verify_connectivity())
        except Exception as e:
            print(e)
    

  • answered 2022-03-23 11:47 Thennan

    Try

    link = "bolt+ssc://" + sys.argv[1]
    

    or

    link = "neo4j+ssc://" + sys.argv[1]
    
    

    instead of

    link = "bolt://" + sys.argv[1]
    

    The '+ssc' variants are URI schemes for encrypted sessions that do not check certificates. Refer to the Neo4j Driver manual for more details on the connection URI.
    Notes from the Neo4j migration guide

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum