Laz*_*har 6 mongodb node.js google-compute-engine google-cloud-platform google-cloud-functions
我的Google Cloud Functions与在Compute Engine VM Instance上运行的MongoDB数据库完美配合,但前提是我在Function的MongoClient连接字符串中使用实例的外部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
Run Code Online (Sandbox Code Playgroud)
我的mongodb.conf如下:
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,10.*.*.*
Run Code Online (Sandbox Code Playgroud)
显然,10.*.*.*是我的内部计算引擎实例.我在Google云端功能中的MongoClient连接字符串中使用的IP相同.
如果我使用我的外部IP并在mongodb.conf中我放了0.0.0.0,它可以工作.我希望云功能使用VM的内部IP连接到我的MongoDB计算引擎实例.
有帮助吗?
| 归档时间: |
|
| 查看次数: |
354 次 |
| 最近记录: |