关闭远程连接的Gremlin服务器-如何自动重新连接? [英] Gremlin server withRemote connection closed - how to reconnect automatically?

查看:203
本文介绍了关闭远程连接的Gremlin服务器-如何自动重新连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用withRemote将我的Java应用程序连接到在带有dynamodb存储后端的AWS中运行的gremlin服务器.几秒钟(〜3.3秒)后,我得到了连接超时:

I am using withRemote to connect my java application to gremlin server running in AWS with dynamodb storage backend. I am getting connection timeout after few seconds (~3.3 seconds):

org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException]]

我需要弄清楚如何重新连接,这意味着检测连接是否关闭.我不确定如何检测到这一点.使用图形遍历时,出现上述异常,是否有办法先发现它并重新连接,还是在配置中有一个选项可以自动重新连接(例如在此关​​闭之前创建新的连接),这样我的应用程序就始终处于连接状态?

I need to figure out how to reconnect which means detecting if the connection is closed. I am not sure how to detect that. I get the above exception when I use the graph traversal, is there a way to discover it before and reconnect or is there an option in configuration that allows reconnecting automatically (like create new connection before this one closes) so my application is always connected?

如果需要,这就是我的连接方式-当前应用程序启动时,连接部分为单例:

In case you need, this is how I am doing connection - currently connection part is singleton when the application starts:

  this.graph = EmptyGraph.instance();
  GryoMessageSerializerV1d0 gryoMessageSerializerV1d0 = new GryoMessageSerializerV1d0(
        GryoMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()));
  this.cluster = Cluster.build().serializer(gryoMessageSerializerV1d0)
        .addContactPoint(configuration.getString("graphDb.host", "localhost"))
        .port(configuration.getInt("graphDb.port", 8182)).create();
  this.graphTraversalSource = this.graph.traversal().withRemote(DriverRemoteConnection.using(cluster));

推荐答案

我觉得这个问题已经通过connection.keepAlive

I feel like this problem is already solved with connection.keepAlive configuration option. It defaults to 180 seconds so it's longer than your timeout of 60 seconds in your load balancer which is why it gives up.

也就是说,驱动程序应该自行重新连接.在给定connectionPool.reconnectInterval的情况下,它一直在尝试执行此操作,但是也许在某些情况下,您很快就耗尽了所有连接,直到出现该错误....不确定.无论哪种方式,希望

That said, the driver should be reconnecting on its own. It's constantly trying to do that given the connectionPool.reconnectInterval but perhaps there is a condition where you're quickly exhausting all the connections to the point of getting that error....not sure. Either way, hopefully the

这篇关于关闭远程连接的Gremlin服务器-如何自动重新连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆