How to call Cloud Foundry API from a node.js application deployed?


Juan Antonio BreƱa Moral <bren at juanantonio.info...>
 

Hi,

I would like to know how to call cloud foundry API from a node.js application.

From local, it is very easy to call the API using a absolute address:

https://api.MY_PUBLIC_IP.xip.io/v2/info
http://apidocs.cloudfoundry.org/214/info/get_info.html

but when I deploy the node application to the platform, I can't connect with the API and I receive the following error:

{"error":{"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect"}}

I checked Application Security Group, but no rule is associated to the space used with the application.
http://docs.pivotal.io/pivotalcf/adminguide/app-sec-groups.html

Does exist a way to call the API from a application deployed?
Does exist a VCAP variable similar to: process.env.VCAP_APP_PORT to avoid this problem?

Many thanks in advance

Juan Antonio

Join cf-dev@lists.cloudfoundry.org to automatically receive all group messages.