ibm-watson-iot / iot-nodejs

Client libraries and samples for connecting to IBM Watson IoT using nodejs
https://internetofthings.ibmcloud.com
Eclipse Public License 1.0
180 stars 100 forks source link

ApplicationConfig.js: this.sharedSubscription is always falsy in getClientId() #142

Closed jsuntiok closed 4 years ago

jsuntiok commented 4 years ago

We are looking for this.options.mqtt.sharedSubscription in constructor and we set that to false if it's not set. No this.sharedSubscription is set.

JonahLuckett commented 4 years ago

Hey - I'll look into this for you.

There are the 2 primary ways to set your sharedSubscription to true by either using the environment variables export WIOTP_OPTIONS_MQTT_SHAREDSUBSCRIPTION = true

or by including a .yaml file, eg:

   identity:
      appId: myApp
    auth:
      key: myKey
      token: myToken
    options:
      domain: internetofthings.ibmcloud.com
      mqtt:
        sharedSubscrption: true
        port: 8883
        transport: tcp
        cleanStart: false

Either way by default it will always be set to false if no value is provided. https://github.com/ibm-watson-iot/iot-nodejs/blob/dfd5ced69f40ee4ce0438f9166d0f4e938c8a99c/src/application/ApplicationConfig.js#L101

Just so I can better understand where this issue lies, which of the 2 methods above did you use to set your sharedSubscription setting?

Suntikka commented 4 years ago

Answering using my other account. I'm actually creating a ApplicationConfig instance and passing { mqtt: {sharedSubscription: true} } as options. So the instance should have the following: instance.options.mqtt.sharedSubscription = true. This seems to be the case with setting it via environment variable too.

However in getClientId()-method we check instance.sharedSubscription, which isn't set anywhere.

JonahLuckett commented 4 years ago

Ah I see now - thanks for bringing this up, I've corrected the call in getClientId() to "this.options.mqtt.sharedSubscription". Thanks again.