eclipse-paho / paho.mqtt.java

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

MessageListener behaves in an odd way #480

Open slavino opened 6 years ago

slavino commented 6 years ago

bug exists in release for Maven

org.eclipse.paho org.eclipse.paho.client.mqttv3 1.2.0
        MqttClient client = new MqttClient(broker, clientId, persistence);

        client.setCallback(new HHACallBack());

        MqttConnectOptions options = new MqttConnectOptions();
        options.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1);

        client.connect(options);

        client.subscribe("#", new TopicMessageListener());
        client.subscribe("$SYS/#", new SystemTopicMessageListener());

The class TopicMessageListener subscribed to "#" receives as well "$SYS/#" so it seems those aren't properly filtered.

jpwsutton commented 6 years ago

@slavino Are you saying that your first subscription for # receives messages sent to $SYS/#? This would be expected behaviour, as $SYS/# would match #

slavino commented 6 years ago

according to which specification?

http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html

4.7.2 Topics beginning with $ The Server MUST NOT match Topic Filters starting with a wildcard character (# or +) with Topic Names beginning with a $ character [MQTT-4.7.2-1]. The Server SHOULD prevent Clients from using such Topic Names to exchange messages with other Clients. Server implementations MAY use Topic Names that start with a leading $ character for other purposes.
etc.