Reputation: 49
Using the sample code from Gremlin.net (V 3.3.2) I'm trying to connect to Cosmos DB. I receive the error below when task.Wait() executes:
"WebSocketException: The server returned status code '200' when status code '101' was expected"
Any ideas why this is failing? Same code works fine with Amazon Neptune.
var gremlinServer = new GremlinServer(hostname, port, enableSsl: true,username: "/dbs/" + database + "/colls/" + collection,password: authKey);
using (var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType))
var task = gremlinClient.SubmitAsync<dynamic>(query.Value);
task.Wait();
Upvotes: 3
Views: 1569
Reputation: 222572
As Tom mentioned, posting an answer
When you are creating the client the hostname should be different from the documentdb which is something like
sample.gremlin.cosmosdb.azure.com
the code will look like
private static GremlinServer GetGremlinServer(IConfigurationRoot builder)
{
var hostname = builder["cosmosDBConnection:gremlinEndpoint"];
var port = builder.GetValue<int>("cosmosDBConnection:gremlinPort", 443);
var authKey = builder["cosmosDBConnection:authKey"];
var databaseId = builder["cosmosDBConnection:databaseId"];
var graphId = builder["cosmosDBConnection:graphId"];
var gremlinServer = new GremlinServer(hostname, port, enableSsl: true, username: $"/dbs/{databaseId}/colls/{graphId}", password: authKey);
return gremlinServer;
}
Upvotes: 3