Genesys Cloud Java SDK: Connection pool exhaustion with async calls

We’re running a Java service that batches contact updates via the Genesys Cloud Java SDK. It works fine for small batches, but when we hit ~500 concurrent requests, the threads start blocking and eventually we get timeouts.

Here’s the setup:

PureCloudPlatform client = PureCloudPlatform.auth().oauth2().clientCredentials(clientId, clientSecret, baseUrl);
RoutingApi routingApi = new RoutingApi(client);

// Inside a parallel stream
contacts.forEach(contact -> {
 try {
 routingApi.postRoutingContactWrappersUpdate(contactId, updateBody);
 } catch (ApiException e) {
 log.error("Failed to update", e);
 }
});

The error I’m seeing in the logs is:

io.swagger.client.ApiException: Connection pool timed out waiting for connection
 at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:312)
 ...```

I know the default `HttpClientBuilder` in the SDK uses a basic pool. I tried setting the pool size manually on the `ApiClient` instance, but the SDK doesn't expose the underlying `PoolingHttpClientConnectionManager` easily for configuration.

How do you guys handle high-throughput scenarios with the Java SDK? Should I be creating a custom `ApiClient` with a tuned `CloseableHttpClient`, or is there a recommended pattern for reusing connections across these batch jobs?

Docs state: “The SDK uses an internal connection pool.” You’re likely hitting the default limit.

// Set max connections explicitly
PureCloudPlatform.setDefaultMaxConnections(100);

Check your token refresh rate too. If you’re creating new clients per thread, you’ll burn out the pool faster.