eclipse / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.12k stars 883 forks source link

SubOpts bits not getting set #564

Closed joelcdunn closed 6 years ago

joelcdunn commented 6 years ago

Synopsis: Setting the BITs NoLocal and the other SubOpts parameters using the Java Client, however we are not seeing them set when the SUBSCRIBE gets to the Server, only the QoS of SubOpts makes the trip.

Test Case sets QoS:2 and NoLocal in the Subscription Options for topic

Code Snippet: case PAHOV5: org.eclipse.paho.mqttv5.common.MqttSubscription [] subs = new org.eclipse.paho.mqttv5.common.MqttSubscription[1]; subs[0] = new org.eclipse.paho.mqttv5.common.MqttSubscription(topic, subopt&3); System.out.println("MqttSubscription: " + subs[0]); if ((subopt&4) != 0){ subs[0].setNoLocal(true); System.out.println("setting noLocal true"); } if ((subopt&8) != 0){ subs[0].setRetainAsPublished(true); System.out.println("setting retainAsPublished true"); } if ((subopt&0x30) != 0){ subs[0].setRetainHandling((subopt&0x30)>>4); System.out.println("setting retainHandling"); } System.out.println("MqttSubscription: " + subs[0]);

        MqttProperties mprops2 = new MqttProperties();
        if (subid != null ) {
            mprops2.setSubscriptionIdentifier(subid);
        }

        org.eclipse.paho.mqttv5.client.IMqttToken subToken = null;
        try {    
            subToken = pahoConnv5.subscribe(subs, null, null, mprops2);
            subToken.waitForCompletion();
            grantedQoS = subToken.getReasonCodes();
        }

Test Case Log File:

TESTACTIONS: noLocal_Sub 2018-07-194 22:30:39.691+0000 Connected to: 169.53.146.15 @ 3222 MqttSubscription: MqttSubscription [mutable=true, topic=iot-2/evt/subOptsNoLocal/fmt/#, qos=2, noLocal=false, retainAsPublished=false, retainHandling=0] setting noLocal true MqttSubscription: MqttSubscription [mutable=true, topic=iot-2/evt/subOptsNoLocal/fmt/#, qos=2, noLocal=true, retainAsPublished=false, retainHandling=0]

MQTT Server Log Snippets:

MQTT receive 10 CONNECT connect=52 rc=0: len=45 00044d515454 05 02 0023 03 22 0000 001d 613a6f72 6734696f 74323a73 75624f70 74734e6f 4c6f6361 6c3a5375 62 [..MQTT...#."....a:org4iot2:subOptsNoLocal:Sub]

MQTT send 20 CONNACK connect=52: len=14 00000b21 01002200 08270040 0000 [...!.."..'.@..]

MQTT receive 82 SUBSCRIBE connect=52: len=36 0001 00 001e 696f74 2d322f65 76742f73 75624f70 74734e6f 4c6f6361 6c2f666d 742f23 02
[.....iot-2/evt/subOptsNoLocal/fmt/#.] ==> Packet 1, No Properties, topic, SubOpts=0x02 THIS IS JUST QoS:2, NoLocal 0x04 was lost!

MQTT send 90 SUBACK connect=52: len=4 00010002
[....]

joelcdunn commented 6 years ago

unable to reproduce this 7/20 with PAHO trace enabled or not.