2

我正在尝试在 python 中运行一段代码,它使用来自 Microsoft Azure 的 Cosmos DB。我目前正在使用 gremlinpython 3.2.6 和最新版本的 Cosmos(默认在 microsoft azure 上),但两者之间似乎存在一些兼容性问题。

当我运行我的代码时,出现以下错误;

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

我已经读到我应该尝试使用 GraphSON v2 而不是 V3,但不知道如何,有人可以帮忙吗?

4

5 回答 5

1

欢迎来到这个社区。您只需确保使用 GraphSON v2 的架构,因为它是 Azure Cosmos DB 中支持的版本。检查您正在使用的 json 并确保遵循支持的架构。您在此链接中有一些示例。

于 2020-03-16T13:22:07.507 回答
1

使用 C#,如果您将连接配置放在Startup.cs中,您可以像这样配置它:

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
                );
            }
        );

否则,您应该使用以下 reader、writer 和 mimeType 创建 gremlin 客户端:

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>
 );
于 2021-06-08T19:01:00.397 回答
0

默认情况下 gremlin_python 使用GraphSONSerializersV3d0,因此您必须GraphSONSerializersV2d0在创建客户端时显式传递 :

from gremlin_python.driver import client, serializer

client.Client(
    message_serializer=serializer.GraphSONSerializersV2d0(),
    password="...",
    traversal_source='g',
    url='wss://...:443/',
    username="/dbs/.../colls/...",
)
于 2020-08-11T16:04:05.297 回答
0

mime创建客户端时将其作为类型提供

var client = new GremlinClient(gremlinServer:gremlinServer,mimeType:GremlinClient.GraphSON2MimeType)
于 2020-12-28T02:52:01.587 回答
0

您需要将版本降级到支持的连接器版本。这适用于所有编程语言。对于撰写本文时的 python,它是 3.2.7。

在此处输入图像描述

于 2021-11-11T16:25:18.557 回答