Search code examples
c#azuregremlinazure-cosmosdb-gremlinapigremlinnet

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


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?


Solution

  • The issue was resolved by changing the uri from

    <project-name>.documents.azure.com
    

    to

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

    https://learn.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-