We are building a custom agent desktop widget using the Genesys Cloud Java SDK. The widget needs to fetch real-time agent status and recent interaction metadata to drive a screen pop workflow. Currently, we are making HTTP requests to /api/v2/analytics/conversations/details/query every 2 seconds for each active agent on the team.
The issue is that the default PlatformClient instance seems to be holding onto connections longer than expected. After about 15 minutes of runtime, we start seeing java.net.SocketTimeoutException: connect timed out errors. We suspected the SDK was not reusing connections efficiently, so we tried configuring the underlying OkHttp client with a fixed connection pool.
Here is the initialization code we are using:
OkHttpClient.Builder builder = new OkHttpClient.Builder();
ConnectionPool pool = new ConnectionPool(20, 5, TimeUnit.MINUTES);
builder.connectionPool(pool);
builder.connectTimeout(10, TimeUnit.SECONDS);
builder.readTimeout(10, TimeUnit.SECONDS);
PlatformClient client = PlatformClientFactory.createPlatformClient(builder.build());
client.login("client_id", "client_secret");
We set the max idle connections to 20 and the keep-alive to 5 minutes. We also verified that we are not creating a new PlatformClient instance for every request. We are reusing the same client object across the application lifecycle. Despite this, the number of open sockets on our local machine keeps climbing until the pool is exhausted.
Is there a specific way to force the SDK to release connections back to the pool after the response is consumed? We noticed that if we manually close the InputStream from the response, it sometimes helps, but the SDK abstracts that away. We are using version 14.2.0 of the SDK. Any insights on how to properly tune the connection pool for high-frequency polling scenarios? We don’t want to switch to raw REST calls if we can avoid it.