我试图在python中运行一段代码,它使用来自Microsoft的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,但是不知道怎么做,有人能帮上忙吗?
发布于 2020-03-16 13:22:07
欢迎来到这个社区。您只需要确保使用GraphSON v2的模式,因为它是Azure中支持的版本。检查正在使用的json,并确保遵循支持的模式。在此链接中有一些示例。
发布于 2021-06-08 19:01:00
使用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
);
}
);否则,您应该使用以下阅读器、作者和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>
);发布于 2020-08-11 16:04:05
默认情况下,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/...",
)https://stackoverflow.com/questions/60705905
复制相似问题