1

I am new to google cloud, I recently installed a mongodb cluster on google cloud instance. However I am unable to connect it from my application or Robomongo. Setting its configuration in the below manner in my spring mvc, I am using external ip as a host:

<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
    <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
</bean>

Its giving below exception:

org.springframework.dao.DataAccessResourceFailureException: Timed out after 10000 ms while waiting for a server that matches AnyServerSelector{}. 
Client view of cluster state is {type=Unknown, servers=[{address=104.196.32.97:27017, type=Unknown, state=Connecting}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting for a server that matches AnyServerSelector{}. Client view of cluster state is {type=Unknown, servers=[{address=104.196.32.97:27017, type=Unknown, state=Connecting}]
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:73)
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2011)

There is no tutorial available about integrating mongodb of gcloud with spring application.

Subhrajyoti Majumder
  • 40,646
  • 13
  • 77
  • 103
Sam
  • 327
  • 3
  • 12
  • This is how i am putting the mongo host and port details : in spring config – Sam Jun 28 '16 at 17:13
  • open port 27017 in mongo cloud instance. – Subhrajyoti Majumder Jun 28 '16 at 17:13
  • i did it with below command but still no luck, is there any sample program I can refer to >> gcloud compute firewall-rules create allow-mongodb --allow tcp:27017 – Sam Jun 28 '16 at 17:45
  • are you able to telnet to the server on the port from ur local? – Subhrajyoti Majumder Jun 28 '16 at 18:27
  • nope, please give me steps to how can I open the port and connect my java application to the mongodb hosted on gcloud, I wasted lot of time on this but still couldn't figure out the steps, really appreciate your help – Sam Jun 30 '16 at 17:51
  • find the steps in this [link](http://stackoverflow.com/questions/21065922/how-to-open-a-specific-port-such-as-9090-in-google-compute-engine) – Subhrajyoti Majumder Jul 01 '16 at 03:38
  • Thanks for the help, I finally moved to mlab and it was pretty easy to incorporate in my app. – Sam Jul 27 '16 at 12:33

0 Answers0