4
votes

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.

1
GAE outgoing is limited. you can't connect to arbitrary resources. That has not changed much lately. If you can make MongoDB talk over a HTTP interface you can use that. - Paul Collingwood
Thanks @Paul Collingwood, but how can I be 100% sure? I can't find restrictions description in docs. - divan
It's more about what you are allowed to do then what you are not allowed. Assume everything is disallowed and only what is documented is allowed. Connect to arbitrary resources/ports? You'll need to use the managed instances instead where you can run any code and use any connection method. See here for that: cloud.google.com/appengine/docs/managed-vms Whereas GAE comes with it's own DB (NOSQL/SQL) that it want's you to use, hence your current problem. - Paul Collingwood
Ok, I got it, thanks. - divan

1 Answers

0
votes

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.