Search code examples
mongodbgrailscloud-foundrytunnel

502 Bad Gateway error throw in cloundfoundry tunneling Mongo Database


I used the grails cloudfoundry plugin and tunnel to remote Mongo DB service. The connection is fine since I can do search for the first time, but after couple seconds, the terminal starts print out 502 Bad Gateway error and I am not able to execute any mongo db commands.

| Run cf-tunnel-disconnect to close the current tunnel |

Error Exception in thread "ThreadPoolTaskExecutor-3"
    | Error org.cloudfoundry.caldecott.TunnelException: Error while reading from tunnel
    | Error     at org.cloudfoundry.caldecott.client.TunnelHandler$Reader.run(TunnelHandler.java:172)
    | Error     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    | Error     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    | Error     at java.lang.Thread.run(Thread.java:680)
    | Error Caused by: org.springframework.web.client.HttpServerErrorException: **502 Bad Gateway
    | Error**   at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:92)
    | Error     at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:494)
    | Error     at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:451)
    | Error     at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:409)
    | Error     at org.cloudfoundry.caldecott.client.HttpTunnel.receiveDataBuffered(HttpTunnel.java:150)
    | Error     at org.cloudfoundry.caldecott.client.HttpTunnel.receiveBytes(HttpTunnel.java:140)
    | Error     at org.cloudfoundry.caldecott.client.HttpTunnel.read(HttpTunnel.java:83)
    | Error     at org.cloudfoundry.caldecott.client.TunnelHandler$Reader.run(TunnelHandler.java:148)
    | Error     ... 3 more

Solution

  • That looks like an error handling problem that was fixed in later releases of the cloudfoundry-caldecott-lib. The latest is 0.1.3 and is available from the Spring Source milestone repo (http://repo.springsource.org/libs-milestone/org/cloudfoundry/cloudfoundry-caldecott-lib/).

    I'm not sure what version the Grails plugin uses, but if it's an older version, that would explain why you are seeing this.