GalmWing
GalmWing

Reputation: 751

Cosmos DB Graph doesn't connect when inside a WebApp: An existing connection was forcibly closed by the remote host

I have Console App that is able to connect to and query Cosmos DB Graph instance, but when I try the same inside a WebApp it fails every time with the error "An existing connection was forcibly closed by the remote host"

I'm not doing anything special. The code is as simple as

var gremlinServer = new GremlinServer(hostname, port, enableSsl: true, username: user, password: pass);
using (var gremlinClient = new GremlinClient(gremlinServer))
{
    results = await gremlinClient.SubmitAsync<dynamic>("g.V().limit(10)");
}

Is there any special requirement when running under a Web Application?

Upvotes: 2

Views: 372

Answers (1)

GalmWing
GalmWing

Reputation: 751

Ok, just in case someone is having problems with trying to use Gremlin.Net and Cosmos DB. Each version of Gremlin.Net has issues, but each one has a very specific set of issues. For example, I started with 3.3.1, but it is not properly signed. and I tried to install the latest at the time, 3.3.4, but it just forgets almost all dependencies while installing the nuget, so you cannot even run it.

I'm sticking with 3.3.3, this one also has issues. You cannot just do new GremlinClient(gremlinServer) or you'll get Null exception, you must replace it with new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType)

Also, it will bring System.Net.Http 4.3.0, but that one comes with its own obscure exception

Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility of the base type or be less accessible.

So after installing Gremlin.Net 3.3.3, upgrade System.Net.Http to System.Net.Http 4.3.1

Also, for a Web Application, this is a problem with Visual Studio, it comes bundled with some version of System.Net.Http, I believe 2017 has 4.1.0, so if you install anything that requires a newer version, you must make sure that your WebApp has the nuget version.

Upvotes: 1

Related Questions