Search code examples
ubuntuneo4jgremlinwindows-subsystem-for-linuxgremlinnet

Connect neo4j from .net using gremlin.net


Am trying to connect neo4j local setup(Windows 10 WSL Ubunutu 18.04) using Gremlin.Net library. Neo4j server is started and its running in http://localhost:8182/. When i try to connect using below code, it throws the error System.Net.WebSockets.WebSocketException: 'The server returned status code '404' when status code '101' was expected.' What am i missing here.

           var gremlinServer = new GremlinServer("localhost", 8182);
           var graphsonReader = new GraphSON2Reader(
                                   new Dictionary<string, IGraphSONDeserializer> { { MyType.GraphsonType, new MyTypeReader() } });
           //var graphsonWriter = new GraphSON2Writer(
           //    new Dictionary<Type, IGraphSONSerializer> { { typeof(MyType), new MyClassWriter() } });
           _connection = new GremlinClient(gremlinServer, graphsonReader, new GraphSON2Writer(), GremlinClient.GraphSON2MimeType);
           return _connection;

Solution

  • I'm not sure if you meant to type this but you wrote that "Neo4j server is started and running in....". If you specifically meant Neo4j Server then Gremlin.NET won't connect to that directly. To use that library you would need to install Gremlin Server and configure Neo4j within that.