All PubNub SDKs Now Require Unique Identifiers (UUIDs)

2 min read Keith Lindsay on Mar 4, 2022

The cautionary tale

Our tale begins with a developer trying to rush to prototype their chat application, they found PubNub so easy to get started they skimmed over the documentation and didn’t realize that unique identifiers for each of their application instances would be generated every time the application started.

Being on the MAU pricing plan, which charges for each user, this was a recipe for disaster. Their bill ballooned far beyond their actual usage. If only they had set the UUIDs (UserIDs) in their application instead of using the default random ID generator.

The solution

After hearing this cautionary tale, our team decided to fix this problem by enforcing our best practice policy of requiring the UUID / UserIDs to be set. Previously, if a UUID was not set, PubNub SDKs would randomly generate on when connection was created to PubNub. Often, this would inflate the user numbers and cause customers to be billed more than our actual usage. 

Now when our developer tries to implement PubNub without setting the UUID / UserIDs, they will get an error until they generate one. This allows them to identify each user in their own unique way and ensure that events and messages generated by the user are published to the correct channels.

Identity is one of the key components of a Virtual Space, so by requiring our developers to uniquely identify each, we empower them to utilize the data generated by each user to enhance their application and deliver the best experience to their end users. 

How do you generate your own unique identifier?

Every program language has built in id generators that can be used, however, one of the most common ways to create an identifier for a specific device is to create a hash of something unique to the device. For example, as long as it can’t be reversed, hashing the MAC address of the device or the email address of the user can be a good way to generate a unique identifier that is always associated with the device or the user.

To generate a UUID (UserIDs) for each language, you can visit this Online UUID Generator Tool page. And if you're not already building with PubNub but are looking to get started, you can try our APIs for free here.

Here's a quick python script that will generate some unique user IDs: