无法从我的本地 node.js 服务器连接 aws documentdb
could not connect aws documentdb from my local node.js server
当前状态:
我已经创建了一个 documentdb 集群。
为安全组添加了入站规则以允许来自任何地方的所有流量。
为集群禁用 TLS
在此之后尝试连接到数据库
https://docs.aws.amazon.com/documentdb/latest/developerguide/connect_programmatically.html
但抛出以下错误:
(node:45892) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [aacb-c1.cluster-c3ggyumy9pd2.us-east-2.docdb.amazonaws.com:27017] on first connect [MongoNetworkTimeoutError: connection timed out
当您说从 'local node.js server' 连接时,您是指 运行 在您自己的计算机上连接吗?如果是这样,我相信即使您向入站安全组添加了规则也不会起作用,因为 DocumentDB 在其自己的 VPC 中运行。
这里有一个指南(您基本上还需要在 AWS 中拥有 node.js 服务器 运行):https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-from-outside-a-vpc.html
Amazon DocumentDB 仅限虚拟私有云 (VPC),目前不支持 public 端点。因此,如果您尝试从计算机本地的节点服务器 运行 进行连接,它将无法访问 Amazon DocumentDB publicly。
替代选项:
您可以使用 SSH 隧道从本地环境进行连接。要创建 SSH 隧道,您需要在与 Amazon DocumentDB 集群相同的 Amazon VPC 中有一个 Amazon EC2 实例 运行。您可以参考这里的说明:https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-from-outside-a-vpc.html
您可以尝试 运行 您的应用程序来自在包含 Amazon DocumentDB 集群的同一 VPC 中创建的 EC2 实例(安装了节点)。
当前状态:
我已经创建了一个 documentdb 集群。 为安全组添加了入站规则以允许来自任何地方的所有流量。 为集群禁用 TLS
在此之后尝试连接到数据库 https://docs.aws.amazon.com/documentdb/latest/developerguide/connect_programmatically.html
但抛出以下错误:
(node:45892) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [aacb-c1.cluster-c3ggyumy9pd2.us-east-2.docdb.amazonaws.com:27017] on first connect [MongoNetworkTimeoutError: connection timed out
当您说从 'local node.js server' 连接时,您是指 运行 在您自己的计算机上连接吗?如果是这样,我相信即使您向入站安全组添加了规则也不会起作用,因为 DocumentDB 在其自己的 VPC 中运行。
这里有一个指南(您基本上还需要在 AWS 中拥有 node.js 服务器 运行):https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-from-outside-a-vpc.html
Amazon DocumentDB 仅限虚拟私有云 (VPC),目前不支持 public 端点。因此,如果您尝试从计算机本地的节点服务器 运行 进行连接,它将无法访问 Amazon DocumentDB publicly。
替代选项:
您可以使用 SSH 隧道从本地环境进行连接。要创建 SSH 隧道,您需要在与 Amazon DocumentDB 集群相同的 Amazon VPC 中有一个 Amazon EC2 实例 运行。您可以参考这里的说明:https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-from-outside-a-vpc.html
您可以尝试 运行 您的应用程序来自在包含 Amazon DocumentDB 集群的同一 VPC 中创建的 EC2 实例(安装了节点)。