我正在尝试使用Gremlin npm模块连接到一个Neptune数据库。在测试过程中,我尝试让Gremlin连接到一个不活动的端点和无效的URL,以使系统更具弹性。我预期会抛出某种错误。然而,在无效/不活跃的URL上,图遍历没有任何消息,也没有解决。
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const dc = new DriverRemoteConnection('wss://localhost:80');
const g = traversal().withRemote(dc);
const data = await g.V().limit(1).toList();
console.log(data);
我期望使用无效的远程连接时,
g.V().limit(1).toList()
会抛出错误。同样,承诺从未解决,并且在下一行上的console.log(data)
永远不会运行。如有任何帮助将不胜感激! 我需要某种系统来检测数据库连接是否有效,如果无效,则记录错误。
TypeError [ERR_INVALID_URL]: Invalid URL:
。但是,当我输入wss://localhost:8080
时,没有任何错误或结果显示。我正在捕获异常并使用g.V().limit(1).toList().then(res => console.log(res)).catch(err=>console.log(err));
将其记录。 - deterministic_ramlocalhost
端口?当我在我的系统上尝试时,我正确地抛出了Error: connect ECONNREFUSED 127.0.0.1:8080
异常。 - Kelvin Lawrence