paho.mqtt.java
paho.mqtt.java copied to clipboard
Exception on subscribe with mqttv5 MqttAsyncClient
- [x] Bug exists Release Version 1.2.5 ( Master Branch)
- [ ] Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
- [ ] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
The
1.2.6-SNAPSHOTdoesn't exist in the repository.
When subscribing to a topic with the call client.subscribe(new MqttSubscription(topic, DEFAULT_QOS), listener); I get the following exception:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[?:1.8.0_74]
at java.util.ArrayList.get(ArrayList.java:429) ~[?:1.8.0_74]
at org.eclipse.paho.mqttv5.client.MqttAsyncClient.subscribe(MqttAsyncClient.java:1276) ~[org.eclipse.paho.mqttv5.client-1.2.5.jar:?]
at org.eclipse.paho.mqttv5.client.MqttAsyncClient.subscribe(MqttAsyncClient.java:1205) ~[org.eclipse.paho.mqttv5.client-1.2.5.jar:?]
at de.vwgis.visu.backend.MessageService._subscribe(MessageService.java:183) ~[classes/:?]
at de.vwgis.visu.backend.MessageService.access$4(MessageService.java:180) ~[classes/:?]
at java.util.HashMap.forEach(HashMap.java:1280) [?:1.8.0_74]
at de.vwgis.visu.backend.MessageService$CustomMqttCallback.connectComplete(MessageService.java:197) [classes/:?]
at org.eclipse.paho.mqttv5.client.internal.ConnectActionListener.onSuccess(ConnectActionListener.java:175) [org.eclipse.paho.mqttv5.client-1.2.5.jar:?]
at org.eclipse.paho.mqttv5.client.internal.CommsCallback.fireActionEvent(CommsCallback.java:358) [org.eclipse.paho.mqttv5.client-1.2.5.jar:?]
at org.eclipse.paho.mqttv5.client.internal.CommsCallback.handleActionComplete(CommsCallback.java:285) [org.eclipse.paho.mqttv5.client-1.2.5.jar:?]
at org.eclipse.paho.mqttv5.client.internal.CommsCallback.run(CommsCallback.java:209) [org.eclipse.paho.mqttv5.client-1.2.5.jar:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]
The reason is this https://github.com/eclipse/paho.mqtt.java/blob/6f35dcb785597a6fd49091efe2dba47513939420/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/MqttAsyncClient.java#L1202-L1207 in connection with https://github.com/eclipse/paho.mqtt.java/blob/6f35dcb785597a6fd49091efe2dba47513939420/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/MqttAsyncClient.java#L1272-L1276
Why and how to set a subId when there is this shorthand method?
Workaround is simple by creating the MqttProperties self.
final MqttProperties props = new MqttProperties();
props.setSubscriptionIdentifiers(Arrays.asList(new Integer[] { 0 }));
client.subscribe(new MqttSubscription(topic, DEFAULT_QOS), null, null, listener, props);
@rdasgupt If I submit a PR for this fix today can I be sure that it will be reviewed and, if acceptable, merged for the next release?
This still occurs with 1.2.5 and still requires the workaround.
Do you happen to have any updates on this?
How and why is this still open?
I have just encountered the same problem. Is still an issue version 1.2.5
I can confirm that the problem is still present in version 1.2.5