> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/sdks/java-sdk/java-modules/proxy-floating.md).

# Proxy Floating

The `ProxyFloatingService` is intended to be used with the on-premise [**Floating Server**](/floating-server/floating-server.md) and is part of the [**Floating Client**](/sdks/java-sdk/java-modules/floating-client.md) module.

## Initializing the Proxy Floating Client module

At the **minimum** there are **three parameters** you will need to initialize the SDK:

* `apiKey`, your company API key
* `sharedKey`, company-specific encryption key, used when signing requests
* `productCode`, an alphanumeric code identifying a specific product

The `productCode` is tied to a specific product the license applies to and is defined while creating the product.

**Optional** Configuration parameters for initializing the Floating Client SDK:

* `addShutdownHook` indicates if you want the SDK to automatically release any currently active licenses on the device before you shut down the runtime process. Default is true.
* `enablePeriodicRegister` enables periodic calls to register method to prolong the license usage. It will be prolonged every time the license has passed half of its floating timeout time. Usage time is set through the LicenseSpring platform with the `floatingTimeout` parameter in the product configuration
* `proxyRegisterSubscriber` subscriber on periodic register, default implementation is `IgnoreRegisterEventSubscriber`, but you can add your own implementation to handle the `onSuccess` and `onError` of the periodic register. This, of course, isn't a parameter you need to worry about if you chose not to enable periodic checks.
* `requestLogging` request logging for debug purposes, default is no request logging.
* `appVersion` manually set the version of the application that's using the SDK.
* `enableRetrying` enables the retry option on failed API call to the server. The call can be repeated for up to 4 times. Default is false
* `identityProvider` set a custom `IdentityProvider` which generates unique keys for a particular device. Default implementation is based on `ONCE_PER_PROCESS`. More details on our [**Java Hardware (Device) IDs**](/sdks/java-sdk/java-hardware-device-ids.md)
* `requestTimeout` set the timeout of requests make to API (in seconds), default is 10 seconds

```java
// configuration with only required parameters
// NOTE building a LicenseSpringConfiguration without required parameters will throw a ConfigurationException
try {
  ProxyConfiguration configuration = ProxyConfiguration.builder()
    .host("localhost")
    .port(8080)
    .product("pc")
    .build();
} catch (ConfigurationException e) {
  log.error(e.getCause().getMessage());
}

// Configuration with more parameters
try {
  ProxyConfiguration configuration = ProxyConfiguration.builder()
    .host("localhost")
    .port(8080)
    .product("pc")
    .addShutdownHook(false)
    .enablePeriodicCheck(false)
    .enableRetrying(true)
    .requestTimeout(60L)
    .build();
} catch (ConfigurationException e) {
  log.error(e.getCause().getMessage());
}
```

## ProxyFloatingService

After setting up the SDK configuration, there are a number of methods and objects available to the app developer.

To make the `ProxyFloatingService`, initialize it by passing the `ProxyConfiguration` object you set up earlier.

```java
ProxyFloatingService service = new ProxyFloatingService(configuration);
```

Now you can use the methods that the `ProxyFloatingService` provides.

### register()

Registers the user by making a `ProxyRequest` which contains the product code from the `ProxyConfiguration` and the device ID which is provided by the `IdentityProvider`. Each registration lasts for the time specified in the LicenseSpring platform (floating timeout). In order to prolong the usage of the product, this method needs to be called periodically (this is automatically called in the background if the property `enablePeriodicRegister` in the `ProxyConfiguration` was set to true). Returns the `LicenseData` object which contains information about the license.

```java
try {
  LicenseData licenseData = service.register();
  System.out.println("You have " + licenseData.getFloatingTimeout() + " more minutes.");
} catch (LicenseSpringException e) {
  log.error(e.getCause().getMessage());
}
```

### unregister()

Unregisters the user, which by definition, frees up one user slot on the server. Returns true if the action was successful.

```java
try {
  if (service.unregister()) {
    System.out.println("You have been successfully unregistered from product " + configuration.getProduct());
  }
} catch (LicenseSpringException e) {
  log.error(e.getCause().getMessage());
}
```

### getLicense()

Fetches the license information from the server for the product specified in the `ProxyConfiguration` object.

```java
try {
  if (service.unregister()) {
    System.out.println("You have been successfully unregistered from product " + configuration.getProduct());
  }
} catch (LicenseSpringException e) {
  log.error(e.getCause().getMessage());
}
```

### getSettings()

Retrievers the server settings. The returned `Settings` object contains `registrationExpiryMinutes`, and an array of server addresses.

```java
try {
  Settings settings = service.getSettings();
  System.out.println("There are " + settings.getServers().length + "in your proxy network.");
  System.out.println("The registration expiry time for product " + configuration.getProduct() + " is " +
                     settings.getRegistrationExpiryMinutes() + " minutes");
} catch (LicenseSpringException e) {
  log.error(e.getCause().getMessage());
}try {
  if (service.unregister()) {
    System.out.println("You have been successfully unregistered from product " + configuration.getProduct());
  }
} catch (LicenseSpringException e) {
  log.error(e.getCause().getMessage());
}
```

### pingServer()

Pings the local proxy server.

```java
try {
  service.pingServer();
  System.out.println("The proxy server is up and running. :)");
} catch (LicenseSpringException e) {
  System.out.println("There is something wrong with your local server, this application cannot connect to it.");
  System.out.println("Please check why: " + e.getCause().getMessage());
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.licensespring.com/sdks/java-sdk/java-modules/proxy-floating.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
