首页 > 解决方案 > 关闭 SessionClient 上的连接 - AWS Neptune

问题描述

我使用 aws-neptune。我尝试将我的查询实现为事务性的(使用 sessionClient,例如:https ://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-sessions.html )。但是当我尝试实现它时,关闭客户端会引发异常。有类似我的情况的问题:https ://groups.google.com/g/janusgraph-users/c/N1TPbUU7Szw

我的代码如下所示:

@Bean
public Cluster gremlinCluster()
{
    return Cluster.build()
            .addContactPoint(GREMLIN_ENDPOINT)
            .port(GREMLIN_PORT)
            .enableSsl(GREMLIN_SSL_ENABLED)
            .keyCertChainFile("classpath:SFSRootCAG2.pem")
            .create();
}

private void runInTransaction()
{
    String sessionId = UUID.randomUUID().toString();
    Client.SessionedClient client = cluster.connect(sessionId);

    try
    {
        client.submit("query...");
    }
    finally
    {
        if (client != null)
        {
            client.close();
        }
    }
}

例外是:

INFO (ConnectionPool.java:225) - Signalled closing of connection pool on Host{address=...} with core size of 1

WARN (Connection.java:322) - Timeout while trying to close connection on ... - force closing - server will close session on shutdown or expiration.

java.util.concurrent.TimeoutException

at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771)

有什么建议吗?

标签: gremlintinkerpop3amazon-neptune

解决方案


这可能是您在发送查询时无法观察到的服务器连接问题,因为您没有等待未来完成。

当你做 aclient.submit("query...");时,你会得到一个未来。您需要等待该未来完成以观察任何异常(或成功)。

我建议如下:

  1. 尝试使用 curl 通过健康状态调用来访问服务器,以验证与服务器的连接。
  2. 替换为client.submit("query...");client.submit("query...").all().join();获取与服务器连接期间的错误。

推荐阅读