3

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?

NoobCoder
  • 117
  • 1
  • 11

5 Answers5

1

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.

Hugo Barona
  • 1,303
  • 9
  • 21
  • Thanks for this, I also have one more query. When creating a new graph, i get the following error: `Gremlin Query Execution Error: Cannot add a vertex where the partition key property has value 'null'` My previous graph has the following partition key: `/_partitionKey` but this same key does not seem to work for new graph? – NoobCoder Mar 16 '20 at 14:22
  • You need to specify your partition key when adding your Vertex - issue reported and explained [here](https://github.com/Azure-Samples/azure-cosmos-db-graph-nodejs-getting-started/issues/20) – Hugo Barona Mar 16 '20 at 14:27
  • 1
    This doesn't help - how do you do you set it to ensure you're using GraphSON v2 using gremlin-python? Nothing at that link explains it. – aronchick May 07 '20 at 18:35
  • Even though this is the accepted answer it didn't help me. I managed to figure out how to use `GraphSON v2`, please see my answer: https://stackoverflow.com/a/63362061/1896523 – Heye Aug 11 '20 at 16:07
1

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>
 );
aqteifan
  • 456
  • 1
  • 5
  • 17
0

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/...",
)
Heye
  • 603
  • 6
  • 14
0

Provide it as mime type when you create client

var client = new GremlinClient(gremlinServer:gremlinServer,mimeType:GremlinClient.GraphSON2MimeType)
Gautham M
  • 4,816
  • 3
  • 15
  • 37
0

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

Karthikeyan VK
  • 5,310
  • 3
  • 37
  • 50