Connecting to an Aura instance from a .Net core 2.2 web api

Hi there :slightly_smiling_face:

I'm looking for examples for connecting a .NET Core 2.2 Web.api to a brand new sparkling Neo4j Aura instance. I Figure I need the alpha driver ( 4.0.0-alpha01) as it targets .NET Standard 2, but I am struggeling in finding any tutorials or examples. Something to get me started. I keep getting this Error message: Failed after retried for 6 times in 30000 ms. Make sure that your database is online and retry again.

Almost sounds like maybe it's a networking error, not so much a .Net error. Have you double checked that it's network accessible and the instance allows non-local connections?

I suspect I'm not connecting correctly, however I don't quite know what else to try. Any help would be greatly appriciated. I am able to connect to the db through Neo4jDesktop only if I tick the "Use encrypted connection". Does that correspond to any specific setting in the driver?


public void ConfigureServices(IServiceCollection services)
            string uri = "neo4j://";
            string username = "neo4j";
            string password = "seeeeeeecret";

            services.AddSingleton(GraphDatabase.Driver(uri, AuthTokens.Basic(username, password)));


private async Task<string> Neo4JTestAsync()
            string db = "MyDb";
            string message = "TESTMEDDELANDE";

            IAsyncSession session = _driver.AsyncSession(o => o.WithDatabase(db));
                var greeting = session.WriteTransactionAsync(async tx =>
                    var result = tx.RunAsync("CREATE (a:Greeting) " +
                                        "SET a.message = $message " +
                                        "RETURN a.message + ', from node ' + id(a)",
                        new { message });
                    var res = await result;
                    return "return something eventually";
                return await greeting;
            catch (Exception e)
                return e.Message; // throws "Failed after retried for 6 times in 30000 ms. Make sure that your database is online and retry again"
                await session.CloseAsync();

Hi @david.wandar,did you still getting troubler there?

No its resolved by doing two things.

  1. Had to connect with Encryption.
  2. Had to omit the .WithDatabase (as it is a 4.0-feature)
1 Like