SDKs
...
Tutorials
Licensing Scenarios

Floating Licensing

20min

LicenseSpring enables developers to generate licenses for concurrent usage among application users, using LicenseSpring as the floating license server.

See Floating Licenses for more information about floating licensing.

This guide offers a fundamental overview of how to leverage the floating cloud functionality. This includes instructions on how to register and deregister a floating cloud license, manage timeouts, and implement license borrowing.

By the end of this tutorial, readers will understand when to use floating licenses and how to implement handling of a cloud floating license within their applications.

Prerequisites

Completed the Getting Started tutorials, specifically:

  • Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
  • Activated a license.

Creating a Floating License

The default maximum simultaneous license users and floating timeout period are setting during product creation.

Selecting floating cloud and setting timeout and max simultaneous users
Selecting floating cloud and setting timeout and max simultaneous users


It is also possible to edit these default values when issuing a license.

Editing default values when issuing license.
Editing default values when issuing license.


Floating License Data

Floating licenses encompass a multitude of distinctive fields that are specific to this licensing model. These fields are tailored to the dynamic nature of floating licenses and are designed to cater to the flexible allocation, sharing, and management of software licenses across multiple users and devices.

Checking if a License is Floating

First, developers are able to check whether a license is floating using the following:

C++
C#
Swift
Python


Checking Maximum Floating Users

Our SDKs offer the ability to check the maximum simultaneous license users with:

C++
C#
Swift
Python


Note: Only query this value after online license check or registration (for offline floating).

If this value is reached and another 'checkout' is attempted, our SDKs will throw a MaxFloatingReachedException.

Retrieving Number of Floating Licenses in Use

Our .NET and C++ SDKs also allow developers to check the number of floating licenses currently in use with:

C++
C#
Swift
Python


Floating Timeout

The Floating Timeout determines the timeout duration for a floating license in minutes. This value also influences how often the SDK hits the License Check API. Specifically, the SDK checks the license at half the specified time interval. For example, if the Floating Timeout is set to 60 minutes, the SDK will check the license every 30 minutes.

The timeout of the floating license in minutes and floating license validity end date time (in local time and UTC) can be gotten using the following:

C++
C#
Swift
Python


Registering a License

In contrast to a floating server setup, a floating cloud license demands individual activation on every device aiming to utilize the license.

Therefore, when establishing your floating cloud license arrangement, it is strongly advised to align the "max activations" parameter with or exceed the count specified in the "max simultaneous license users" field.

After activation, the registration process through the SDK becomes straightforward. You have the choice of employing the dedicated registration method or conducting an online check, both of which serve to register your access to the floating cloud license.

C++
C#
Java
Swift
Python


Local checks in the C++ and .NET SDKs, since they are routinely called, confirm that a floating license timeout or borrowing period has not expired. If one of them have expired, the local check throws a FloatingTimeoutExpiredException.

Watchdog Setup

While conventional floating timeouts can suit certain applications, they necessitate manual implementation of checks and register API calls within the codebase.

A case in point is when developers embed online checks for each feature in the code. If a user refrains from utilizing any features for a specific duration, they are timed out and their license is relinquished back to the license pool.

Nevertheless, a more practical approach involves the setup of a background thread, which functions perpetually at set intervals to conduct online checks.

This method ensures proactive license validation, enhancing user experience by eliminating the need for active feature usage and preventing unintended timeouts

C++
C#
Java
Python


Note: The parameters in the setupLicenseWatchdog() method consist of the callback function that will be called back in case off errors, and the timeout in minutes (which is how often online checks are performed).

In the .NET SDK, there is a class, LicenseWatchdogSettings, that holds the settings of the license watchdog and can be used as the lone parameter.

The LicenseWatchdogSettings class consists of the following properties:

  • HandleNoInternet - Boolean that indicates if you want to run license checks more often if NetworkException or LicenseServerException are encountered.
  • NoInternetTimeout - Custom watchdog timeout in seconds for the case if NetworkException or LicenseServerException are encountered.
  • RunCallbackOnEveryCheck - Boolean that indicates if you want to run the callback after every check.
  • Timeout - timeout in minutes, 0 means use default.
  • WatchdogCallback - LicenseWatchdogCallback object, which is a function to be called in case of errors or after every check.

WatchdogException called if watchdog thread cannot be started.

License Borrowing

License borrowing facilitates users in temporarily "checking out" a floating license directly from the license server. This permits the utilization of the license for a defined period.

Once the license is no longer required or when the predetermined time elapses, the user can proceed to "check in" the license.

For more information, see our Floating Licenses documentation.

Floating licenses can be borrowed using two different methods:

  1. Defining the hours and days from current time that the user will borrow the license for
  2. Defining end date in UTC in format "%Y-%m-%dT%H:%M:%SZ", for example "2022-05-28T15:30:00Z".

Below are the programmatic steps required to implement license borrowing using both strategies:

C++
C#
Swift
Python


Note: With strategy 2 (using an end date in UTC), if the string is left empty, then the license will be borrowed for max possible period.

In C++ and .NET, the BorrowLicenseException is thrown if borrowing is not allowed or the provided borrowing period is larger than the maximum.

When borrowing a license, it's worth mentioning the divergent behaviors of the license watchdog in different programming contexts.

In C++, the license watchdog ceases operation upon borrowing, while in .Net, it temporarily pauses to avoid interfering with the borrowed license's usage.

Returning the Floating License

Given the finite availability of registration slots, it's crucial to release these spots when not in active use. To facilitate this, the process of deregistering a license becomes vital, enabling other users to register their licenses on their respective devices.

Much like the procedure for registering a floating license, there are several approaches to accomplish license deregistration/release.

One option involves manually initiating the deregistration process within your code, allowing you to efficiently free up a registration slot associated with a floating license.

C++
C#
Swift
Python


Note: The Boolean parameter in these manual license release determines whether this method should throw exceptions. By default, it is false.

Alternatively, you have the option to leverage the auto-release functionality.

This feature ensures that whenever your license object undergoes destruction, the associated floating license is automatically released from the device.

This proves beneficial because in scenarios such as application closure or crashes, the license object is typically destroyed, facilitating an automatic release of the license.

Notably, this feature is already activated by default within the SDK, contributing to streamlined license management.

C++


Note: The parameter in setAutoRelease() is used to indicate whether the SDK should automatically release floating license in the destructor.