NoobCoder
NoobCoder

Reputation: 137

How do i use GraphSON v2 instead of v3?

i am trying to run a piece of code in python which uses Cosmos DB from Microsoft Azure. I am currently using gremlinpython 3.2.6 and the latest version of Cosmos (default on microsoft azure) but there seems to be some compatibility issues between the two.

When i run my code i get the following error;

GremlinServerError: 498: 

ActivityId : 5c05bb15-3aa1-41b8-9c10-ab3015152eab
ExceptionType : GraphMalformedException
ExceptionMessage :
    Gremlin Malformed Request: GraphSON v3 IO is not supported.
    GremlinRequestId : 5c05bb15-3aa1-41b8-9c10-ab3015152eab
    Context : global
    GraphInterOpStatusCode : MalformedRequest
    HResult : 0x80131500

I have read that I should try using GraphSON v2 instead of V3 but don't know how, can anyone help?

Upvotes: 3

Views: 2389

Answers (5)

Karthikeyan VK
Karthikeyan VK

Reputation: 6006

You need to downgrade the version to the supported connector version. This applies to all programming languages. For python as of this writing, it is 3.2.7.

enter image description here

Upvotes: 0

aqteifan
aqteifan

Reputation: 504

Using C#, If you put your connection config in Startup.cs you can configure it like this:

services.AddSingleton<GremlinClient>(
            (serviceProvider) =>
            {
                var gremlinServer = new GremlinServer(
                    hostname: "<account>.gremlin.cosmosdb.azure.com",
                    port: <port>,
                    enableSsl: true,
                    username: "/dbs/<db>/colls/<collection>",
                    password: ""
                    );
                var connectionPoolSettings = new ConnectionPoolSettings
                {
                    MaxInProcessPerConnection = 32,
                    PoolSize = 4,
                    ReconnectionAttempts = 3,
                    ReconnectionBaseDelay = TimeSpan.FromSeconds(1),
                };
                var mimeType = "application/vnd.gremlin-v2.0+json";
                return new GremlinClient
                (
                    gremlinServer: gremlinServer,
                    graphSONReader: new GraphSON2Reader(),
                    graphSONWriter: new GraphSON2Writer(),
                    mimeType: mimeType,
                    connectionPoolSettings: connectionPoolSettings
                );
            }
        );

Otherwise you should create the gremlin client with the following reader, writer and mimeType:

var mimeType = "application/vnd.gremlin-v2.0+json";
var client = new GremlinClient
(
      gremlinServer: <your server>,
      graphSONReader: new GraphSON2Reader(),
      graphSONWriter: new GraphSON2Writer(),
      mimeType: mimeType,
      connectionPoolSettings: <your connection pool>
 );

Upvotes: 1

Rajesh Dhiman
Rajesh Dhiman

Reputation: 1

Provide it as mime type when you create client

var client = new GremlinClient(gremlinServer:gremlinServer,mimeType:GremlinClient.GraphSON2MimeType)

Upvotes: 0

Heye
Heye

Reputation: 623

By default gremlin_python uses the GraphSONSerializersV3d0, so you have to explicitly pass the GraphSONSerializersV2d0 when creating the client:

from gremlin_python.driver import client, serializer

client.Client(
    message_serializer=serializer.GraphSONSerializersV2d0(),
    password="...",
    traversal_source='g',
    url='wss://...:443/',
    username="/dbs/.../colls/...",
)

Upvotes: 0

Hugo Barona
Hugo Barona

Reputation: 1398

welcome to this community. You just need to ensure that you use the schema of the GraphSON v2, since it is the version supported in Azure Cosmos DB. Check the json you are using and ensure that follows the supported schema. You have some examples in this link.

Upvotes: 1

Related Questions