Closed Spyna closed 3 years ago
Hi, the driver default timeouts are a bit too aggressive for cloud providers. I suggest that you do the following:
src/main/resources
directory.datastax-java-driver {
advanced {
connection {
connect-timeout = 10 seconds
init-query-timeout = 10 seconds
set-keyspace-timeout = 10 seconds
}
heartbeat.timeout = 10 seconds
control-connection.timeout = 10 seconds
control-connection.schema-agreement.timeout = 10 seconds
metadata.schema.request-timeout = 10 seconds
}
Of course you can adjust the values above to your needs. FYI the timeout that is firing in your example is init-query-timeout
.
You can also use this file to customize the driver in many other ways, see this page for details.
Alternatively, you can switch to a more recent version of the driver: starting with 4.8, the default timeouts were raised.
To include a different version of the driver, for example 4.9, include the following in your pom file:
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
<version>4.9.0</version>
</dependency>
If you are using other driver artifacts, e.g. java-driver-query-builder
or java-driver-mapper-runtime
you must declare them as well with the overriding version (4.9.0 in my example).
Thank you, the first solution worked.
The second didn't because com.datastax.oss.quarkus:cassandra-quarkus-client
uses some mothods that are available only in the version 4.7.2
of com.datastax.oss:java-driver-core
After reading this guide from AWS at this link: https://docs.aws.amazon.com/keyspaces/latest/devguide/using_java_driver.html I came up with the right configuration:
datastax-java-driver {
basic.contact-points = [ "cassandra.eu-central-1.amazonaws.com:9142"]
advanced.auth-provider{
class = PlainTextAuthProvider
username = "<my username>"
password = "<my password>"
}
basic.load-balancing-policy {
local-datacenter = "eu-central-1"
}
advanced.ssl-engine-factory {
class = DefaultSslEngineFactory
truststore-path = "<path to the keystore>"
truststore-password = "my_password"
}
advanced {
connection {
connect-timeout = 10 seconds
init-query-timeout = 10 seconds
set-keyspace-timeout = 10 seconds
}
heartbeat.timeout = 10 seconds
control-connection.timeout = 10 seconds
control-connection.schema-agreement.timeout = 10 seconds
metadata.schema.request-timeout = 10 seconds
}
}
Note:
Instead of adding the path to the trustStore in the configuration file, you can also add the trustStore path directly in the application code or you can add the path to the trustStore to your JVM arguments.
Hi, I just started using Quarkus, and I'm figuring out how to connect to Aws keyspaces (Cassandra) using cassandra-quarkus-client.
I created a new project using https://code.quarkus.io/ and these extensions:
The dependency for cassandra:
With this configuration:
It prints this error
┆Issue is synchronized with this Jira Task by Unito