eclipse-paho / eclipse-paho/paho.mqtt.java
Weird usage pattern required in multi-broker setup
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 919
- PR merge metrics
- No merged PRs in 30d
Description
:heavy_check_mark: Bug exists Release Version 1.2.5 (Master Branch)
:grey_question: Bug exists in MQTTv3 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
:grey_question: Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)
I have a multi-broker setup, and I'm passing multiple URIs to the library via `MqttConnectionOptions`'s `setServerURIs` in the `connect` method.
All `MqttAsyncClient` constructors require a single URI (not adequato to my use case), which is then ignored if `setServerURIs` is used. However this address is validated and an exception is throw if an empty string or a null is passed.
```
java.lang.IllegalArgumentException: missing scheme in broker URI:
at org.eclipse.paho.mqttv5.client.internal.NetworkModuleService.validateURI(NetworkModuleService.java:61)
at org.eclipse.paho.mqttv5.client.MqttAsyncClient.(MqttAsyncClient.java:573)
at org.eclipse.paho.mqttv5.client.MqttAsyncClient.(MqttAsyncClient.java:439)
```
As a workaround I can pass a fake address to the constructor, but it's ugly and confusing.
Contributor guide
Research direction
Start with the MqttAsyncClient constructors and MqttConnectionOptions.setServerURIs, then inspect the NetworkModuleService.validateURI call shown in the stack trace. Reproduce the empty or null constructor URI case with multiple server URIs configured. Done means a multi-broker client no longer needs a fake constructor address while invalid broker URIs remain rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100