Skip to content

Commit aa82b7a

Browse files
author
bzhangxmt
committed
Fix bug 443744 - MQTTClient generate invalid client id for Websphere MQ 8.0
The client id is valid for MessageSight and also RSMB. But for some reason, the generated id is not valid for Websphdere MQ 8.0. The '-' in the clientID prefix is considered as an invalid character in WebSphere MQ server. This fix removes this character to make it compatible with the most of MQTT brokers. Bug: 443744 Signed-off-by: bzhangxmt <zhbinbj@cn.ibm.com>
1 parent 103f3eb commit aa82b7a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/MqttAsyncClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class MqttAsyncClient implements IMqttAsyncClient { // DestinationProvide
7878
private static final String CLASS_NAME = MqttAsyncClient.class.getName();
7979
private static final Logger log = LoggerFactory.getLogger(LoggerFactory.MQTT_CLIENT_MSG_CAT,CLASS_NAME);
8080

81-
private static final String CLIENT_ID_PREFIX = "paho-";
81+
private static final String CLIENT_ID_PREFIX = "paho";
8282
private static final long QUIESCE_TIMEOUT = 30000; // ms
8383
private static final long DISCONNECT_TIMEOUT = 10000; // ms
8484
private static final char MIN_HIGH_SURROGATE = '\uD800';
@@ -791,7 +791,7 @@ public void setCallback(MqttCallback callback) {
791791
}
792792

793793
/**
794-
* Returns a randomly generated client identifier based on the the fixed prefix (paho-)
794+
* Returns a randomly generated client identifier based on the the fixed prefix (paho)
795795
* and the system time.
796796
* <p>When cleanSession is set to false, an application must ensure it uses the
797797
* same client identifier when it reconnects to the server to resume state and maintain
@@ -800,7 +800,7 @@ public void setCallback(MqttCallback callback) {
800800
* @see MqttConnectOptions#setCleanSession(boolean)
801801
*/
802802
public static String generateClientId() {
803-
//length of nanoTime = 15, so total length = 20 < 65535(defined in spec)
803+
//length of nanoTime = 15, so total length = 19 < 65535(defined in spec)
804804
return CLIENT_ID_PREFIX + System.nanoTime();
805805
}
806806

0 commit comments

Comments
 (0)