从AppEngine应用程序访问MongoDB [英] Accessing MongoDB from AppEngine app

查看:79
本文介绍了从AppEngine应用程序访问MongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Golang编写的应用程序,可以与MongoDB一起使用。我也可以运行MongoDB的虚拟机实例,部署为Click-to-deploy。



我可以连接到外部MongoDB实例,该应用程序可以在本地运行,并且可以在VM实例上运行GAE,但在以appengine实例启动时(即通过goapp部署),不是。在日志中,我看到无法访问服务器错误。我测试了所有网络配置,并在我的'默认'网络中打开了MongoDB端口。



我发现一些文章和帖子说你不能使用MongoDB和appengine ,并需要与Datastore一起使用,但它们都很旧(如2011/2012),并且我无法在AppEngine文档中找到确认。



所以问题是:


  • 如果可以,我可以使用GAE托管的MongoDB和我的AppEngine应用程序吗?
  • 我可以使用appengine实例调试此连接问题吗?


预先致谢。 由于appengine沙箱的限制,你似乎不能使用来自appengine应用程序的直接MongoDB连接。
https://cloud.google.com/appengine/docs/managed -vms /
网络访问:只能通过App Engine服务(包括出站套接字)

通过HTTP REST接口访问MongoDB的可能性,但这不是我的情况。


I have an app, written in Golang which works with MongoDB. I also have running VM instance of MongoDB, deployed with Click-to-deploy.

I can connect to external MongoDB instance, the app works locally, and on VM Instance on GAE, but NOT when started as appengine instance (i.e. via goapp deploy). In logs I see 'no reachable servers' error. I've double tested all network configuration and opened MongoDB port in my 'default' network.

I found some articles and posts that say you can't use MongoDB with appengine, and need to go with Datastore, but they all are quite old (like 2011/2012) and I can't find confirmation in AppEngine docs.

So the questions are:

  • can I use GAE-hosted MongoDB with my AppEngine application?
  • if yes, how can I debug this connectivity issue with appengine instances?

Thanks in advance.

解决方案

It seems that you can't use direct MongoDB connection from appengine app due to the restricted nature of appengine sandbox. From https://cloud.google.com/appengine/docs/managed-vms/: Network Access: Only via App Engine services (includes outbound sockets)

There are some possbilities to access MongoDB via HTTP REST interface, but it's not my case.

这篇关于从AppEngine应用程序访问MongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆