Home > Mobile >  Why is my gremlin.net gremlin client not working with azure cosmos graph db
Why is my gremlin.net gremlin client not working with azure cosmos graph db

Time:05-04

I've set up a serverless azure cosmos graph db account and now I'm trying to connect to it using the following code:

.AddSingleton(s =>
    {
        var connectionPool = new ConnectionPoolSettings
        {
            MaxInProcessPerConnection = 32,
            PoolSize = 4,
            ReconnectionAttempts = 4,
            ReconnectionBaseDelay = TimeSpan.FromSeconds(1)
        };
        var server = new GremlinServer("<project-name>.documents.azure.com", 443, true, "/dbs/<DatabaseName>/colls/<GraphName>", "<primary key>");
        return new GremlinClient(server, connectionPoolSettings: connectionPool);
    })

The GremlinClient throws an Exception with the message

The server returned status code '200' when status code '101' was expected.

I'm using Gremlin.Net 3.6.0 with NET 6 Any ideas?

CodePudding user response:

If you were connecting well with earlier versions of Gremlin.Net you might want to revert. According to their website their supported version is 3.4.6. While later versions along 3.4.x might work, it might require more configuration (like, I think you might have to switch the serializer as I dont think CosmosDB supports the GraphBinary serializer) and you'd have to take care to not use certain features that newer versions of TinkerPop have that 3.4.6 did not.

CodePudding user response:

The issue was resolved by changing the uri from

<project-name>.documents.azure.com

to

<project-name>.gremlin.cosmosdb.azure.com

https://docs.microsoft.com/en-us/azure/cosmos-db/graph/gremlin-api-faq#why-am-i-getting-the--websocketexception--the-server-returned-status-code--200--when-status-code--101--was-expected--error-

  • Related