Skip to content

Commit

Permalink
Modified client ID generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
hemikak committed Aug 12, 2015
1 parent a532f0b commit 1228ee6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 1228ee6

Please sign in to comment.