Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
How to test service instance in CF

I've created service instance of service from the market place e.g. instance of mongoDB and my question if I want to develop locally (on my local machine )and connect to this service instance how can I do it?

I want to test my app against created instance of backing service ,how i can do it simple ...? Example will be very helpful

UPDATE: I try to connect to MongoDB instance which is on cloud foundry from my locall app. (If I put the app I was able to connect successfully but I want to connect from my local pc i.e. run my application locally)

I got the following db (json) credentials:

     {
  "mongodb": [
    {
      "credentials": {
        "dbname": "CFad18ZNGYzzrrts",
        "hostname": "10.11.123.30",
        "password": "RttomuAV9yvhwHm_",
        "port": "36232",
        "ports": {
          "27017/tcp": "36232",
          "28017/tcp": "49255"
        },
        "uri": "mongodb://xppt7gdk1G9Y1pd3:RttomuAV9yvhwHm_@10.11.123.30:36232/CFad18ZNGYzzrrts",
        "username": "xppt7gdk1G9Y1pd3"
      },
      "label": "mongodb",
      "name": "mod",
      "plan": "v3.0-container",
      "provider": null,
      "syslog_drain_url": null,
      "tags": [
        "mongodb",
        "document"
      ],
      "volume_mounts": []
    },

when I connect to this DB via push my I did the following which works

if (process.env.VCAP_SERVICES) {
    var val = JSON.parse(process.env.VCAP_SERVICES)
    mongoose.connect(val['mongodb'][0].credentials.uri, function (err) {

... Now I copy the config above to my project (under config/config.json) and try to connect from my local app via this and its not working

var config = require('../config/config.json');

mongoose.connect(val['mongodb'][0].credentials.uri, function (err

The error is

failed to connect to server [10.11.123.30:36232] on first connect
    at Pool.<anonymous> (/Users/f53356/WebstormProjects/dlStackDemo/node_modules/mongodb-core/lib/topologies/server.js:325:35)
    at emitOne (events.js:96:13)
    at Pool.emit (events.js:188:7)

Any idea how to over come this, I use the URI when my app running on CF but now Im not able to run it from my pc locally and connect to the service instance in CF,any idea?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Ryan,

The mongodb service is an experimental service available in Bluemix that you can access only via a Cloud Foundry application, hence you cannot connect it from your local machine.

If you want to use a MongoDB database in Bluemix and have your application connect to it you can use the Compose for MongoDB service:

https://console.ng.bluemix.net/catalog/services/compose-for-mongodb

Once you a create an instance of this service it will also create default credentials. You can access the credentials via VCAP_SERVICES from a Bluemix application you bind to the service or you can get the credentials via cf command line:

$ cf service-key your-instance-name Credentials-1

Credentials-1 is the default name of the credentials when you create the Compose for MongoDB instance.

over 4 years ago · Santiago Trujillo Report

0

You can map an external route to your service instance with cf bind-route-service for testing with a local application, but you shouldn't do it.

It is better to have a separate development space within your CloudFoundry organisation and test/deploy everything in CF from the very early beginning.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!