diff --git a/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java b/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java index 702031f..9d1af7c 100644 --- a/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java +++ b/src/main/java/org/apache/jmeter/protocol/mqtt/utilities/Utils.java @@ -17,15 +17,15 @@ public class Utils { /** - * Creates a UUID. + * Creates a UUID. The UUID is modified to avoid "ClientId longer than 23 characters" for MQTT. * * @return A UUID as a string. * @throws NoSuchAlgorithmException */ public static String UUIDGenerator() throws NoSuchAlgorithmException { - SecureRandom prng = SecureRandom.getInstance("SHA1PRNG"); - HashIDGenerator hashIDGenerator = new HashIDGenerator("jmeter-mqtt", 5); - return hashIDGenerator.encrypt(prng.nextLong()); + String clientId = System.currentTimeMillis() + "." + System.getProperty("user.name"); + clientId = clientId.substring(0, 23); + return clientId; } /**