Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. if (process.env.VCAP_SERVICES != null) {
  2. console.log("Using VCAP_SERVICES");
  3. vcap_services = JSON.parse(process.env.VCAP_SERVICES);
  4. }
  5.  
  6. // Parsing credentials from VCAP_SERVICES for binding service
  7. if(vcap_services[config.mqtt.serviceName]){
  8. console.log("Parsing "+config.mqtt.serviceName);
  9. config.mqtt.broker = "mqtt://" + vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.host;
  10. config.mqtt.username = vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.username.trim();
  11. config.mqtt.password = vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.password.trim();
  12. config.mqtt.port = vcap_services[config.mqtt.serviceName][0].credentials.protocols.mqtt.port;
  13. }
  14.  
  15. config.mqtt.options = {
  16. broker: config.mqtt.broker,
  17. reconnectPeriod: 1000,
  18. port: config.mqtt.port,
  19. username: config.mqtt.username,
  20. password: config.mqtt.password
  21. };
  22.  
  23.  
  24. config.mqtt.topic = "/#";
  25. config.mqtt.retain = true; // MQTT Publish Retain
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement