[英]How to connect to my Compute Engine MongoDB instance from Google Cloud Functions using the internal IP?
My Google Cloud Functions works perfectly with my MongoDB database running on a Compute Engine VM Instance, but only if I use the instance's external IP address in the Function's MongoClient connection string. 我的Google Cloud Functions与在Compute Engine VM Instance上运行的MongoDB数据库完美配合,但前提是我在Function的MongoClient连接字符串中使用实例的外部IP地址。
If I use the internal IP, that I would ideally prefer to use for latency and security, it times out after 30 second and shows: 如果我使用内部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
My mongodb.conf is as follows: 我的mongodb.conf如下:
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,10.*.*.*
Obviously, 10.*.*.*
is my internal Compute Engine instance. 显然,
10.*.*.*
是我的内部计算引擎实例。 The same IP I have used in my MongoClient's connection string in my Google Cloud Function. 我在Google云端功能中的MongoClient连接字符串中使用的IP相同。
If I use my external IP and in mongodb.conf I put 0.0.0.0, it works. 如果我使用我的外部IP并在mongodb.conf中我放了0.0.0.0,它可以工作。 I want Cloud Functions to connect to my MongoDB Compute Engine Instance using he VM's internal IP.
我希望云功能使用VM的内部IP连接到我的MongoDB计算引擎实例。
Any help? 有帮助吗?
Currently this is not possible. 目前这是不可能的。 Cloud functions exist on a different network than your project's private VPC, therefore only public IP access is available.
云功能存在于与项目的专用VPC不同的网络上,因此只有公共IP访问可用。
There is an issue created to request this feature, you can add your request on it and subscribe for updates. 创建一个问题来请求此功能,您可以在其上添加您的请求并订阅更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.