KRISHNAVENI avatar image
KRISHNAVENI asked Erick Ramirez commented

How do I configure SocketOptions after upgrading from Java driver 3.6.0 to 4.6.1?

We had customized Socket level configs as follows in 3.6.0:

SocketOptions socketOptions = new SocketOptions();
socketOptions .setReadTimeoutMillis(123456);
socketOptions .setConnectTimeoutMillis(123456);

But I am not able to find how to configure the same in 4.6.1?

java driver
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered Erick Ramirez commented

The Java driver was completely refactored in 4.0 and newer releases are not binary-compatible with earlier versions such as 3.6.0.

To configure the driver in version 4.6.1, you need to set the options via a configuration file (recommended). For example, to set the client timeout:

datastax-java-driver {
  basic.request {
    timeout = 2 seconds

If you don't want to use the recommended configuration file, it is also possible to override the options programmatically by implementing DriverConfig, DriverExecutionProfile and DriverConfigLoader. See the Configuration section of the Java driver docs for details.

I would also recommend you familiarise yourself with the Java driver Upgrade Guide which has detailed instructions on how to migrate your application to the new version. Cheers!

2 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

KRISHNAVENI avatar image KRISHNAVENI commented ·

Thank you. Isn't basic.request.timeout for both write and read. But my requirement is to set only read timeout. How can I configure only read timeout?

0 Likes 0 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ KRISHNAVENI commented ·

They're the same timeout from the driver's perspective.

If you haven't seen it already, the reference configuration in the document I linked explains the timeouts in a bit more detail. Cheers!

0 Likes 0 ·