我的Google Cloud函数与在计算引擎VM实例上运行的MongoDB数据库完美搭配,但前提是我在函数的MongoClient Connection字符串中使用实例的外部IP地址。
如果我使用内部IP,理想情况下,我更喜欢用于延迟和安全性,则在30秒后会出现:
:document-create 4990695959542 DocumentCreate error: failed to connect to server [10.*.*.*:27017] on first connect [MongoError: connection 1 to 10.*.*.*:27017 timed out] document-create 4990695959542
document-create 4990695959542 Function execution took 30025 ms, finished with status: 'timeout' document-create 4990695959542
document-create 4990695959542 Function execution started document-create 4990695959542
我的mongodb.conf如下:
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,10.*.*.*
显然,10.*.*.*
是我的内部计算引擎实例。我在Google Cloud功能中使用的Mongoclient连接字符串中使用的IP。
如果我使用外部IP和MongoDB.Conf,则将0.0.0.0命中率,它可以正常工作。我希望使用He VM的内部IP连接到MongoDB计算引擎实例。
有帮助吗?
当前这是不可能的。云功能与项目的私人VPC不同,因此只有公共IP访问。
。有一个问题来请求此功能,您可以在其上添加您的请求并订阅更新。