Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (process.env.VCAP_SERVICES != null) {
- console.log("Using VCAP_SERVICES");
- vcap_services = JSON.parse(process.env.VCAP_SERVICES);
- }
- // Parsing credentials from VCAP_SERVICES for binding service
- if(vcap_services[config.mqtt.serviceName]){
- console.log("Parsing "+config.mqtt.serviceName);
- config.mqtt.broker = "mqtt://" + vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.host;
- config.mqtt.username = vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.username.trim();
- config.mqtt.password = vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.password.trim();
- config.mqtt.port = vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.port;
- }
- config.mqtt.options = {
- broker: config.mqtt.broker,
- reconnectPeriod: 1000,
- port: config.mqtt.port,
- username: config.mqtt.username,
- password: config.mqtt.password
- };
- config.mqtt.topic = "/#";
- config.mqtt.retain = true; // MQTT Publish Retain
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement