Question

I'm wondering if com.datastax.cassandra:cassandra-driver-core:2.0.0-beta2 can be used with org.apache.cassandra:cassandra-all:1.2.1. I'm using cassandra-maven-plugin:1.2.1-1 (which uses org.apache.cassandra:cassandra-all:1.2.1), adding

start_native_transport: true
native_transport_port: ${cassandra.nativePort}

to the yaml plugin property. I can telnet to the port successfully.

However, when I attempt to connect via the following code,

// Ports.NATIVE has the same value as "${cassandra.nativePort}" above
Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1")
    .withPort(Ports.NATIVE).build();
Session session = cluster.connect();

I get the following exception:

com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1 (com.datastax.driver.core.ConnectionException: [/127.0.0.1] Unexpected error during transport initialization (com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered (com.datastax.driver.core.exceptions.DriverInternalError: Server response from unsupported protocol version: 1))))
    at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:179)
    at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:77)
    at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:868)
    at com.datastax.driver.core.Cluster$Manager.newSession(Cluster.java:888)
    at com.datastax.driver.core.Cluster$Manager.access$200(Cluster.java:792)
    at com.datastax.driver.core.Cluster.connect(Cluster.java:155)

I think the crux of it is Server response from unsupported protocol version: 1.

Does this mean that the 2.0.0-beta2 driver can't be used with Cassandra 1.2.1? Where is the driver/server compatibility matrix?

I've already burned almost a day on this.

Thanks, Matthew

Était-ce utile?

La solution

Yes, it's incompatible. From the java-driver 2.0 requirements:

The driver uses Casandra's native protocol, and this version 2.0 uses the second version of that protocol. As such, this version of the driver requires a version of Cassandra greater than or equal to 2.0 (for Cassandra 1.2 please use the version 1.0 of the driver).

Try downgrading to 1.0, latest version is 1.0.4:

<dependency>
  <groupId>com.datastax.cassandra</groupId>
  <artifactId>cassandra-driver-parent</artifactId>
  <version>1.0.4</version>
</dependency>

Autres conseils

The default protocol level for driver version 2.0 or above is 2. To work with older version of Cassandra (e.g. 1.2) the protocol level needs to be set to 1.

The protocol version can be set on newer drivers using Cluster.withProtocolVersion method like

Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").withProtocolVersion(1) .withPort(Ports.NATIVE).build();

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top