Driver v. 2.3 doesn't work with Cassandra 2.1 - invalid protocol version 4

760 views
Skip to first unread message

Kirill Khistyaev

unread,
Apr 8, 2016, 4:58:41 PM4/8/16
to DataStax C++ Driver for Apache Cassandra User Mailing List
I upgraded our C++ driver to the latest version 2.3 and now I am unable to connect to older versions of Cassandra 2.1.
Driver returns "No hosts available for the control connection" error while in the Cassandra logs I see
"org.apache.cassandra.transport.ProtocolException:Invalid or unsupported protocol version: 4"
I believe this is because driver by default uses version 4 and doesn't downgrade to lower version as promised in the description of cass_cluster_set_protocol_version function.

Everything works with newest version of Cassandra or with older version of C* and newest Java driver.

Kir

Michael Penick

unread,
Apr 8, 2016, 6:27:15 PM4/8/16
to cpp-dri...@lists.datastax.com
Have you looked at the driver logs?

C++ driver 2.3 with Cassandra 2.1 I'm getting seeing the following:

1460154254.466 [WARN] (src/connection.cpp:795:void cass::Connection::notify_error(const std::string &, cass::Connection::ConnectionError)): Host 127.0.0.1 received invalid protocol response Invalid or unsupported protocol version: 4

1460154254.466 [WARN] (src/control_connection.cpp:213:virtual void cass::ControlConnection::on_close(cass::Connection *)): Lost control connection on host 127.0.0.1

1460154254.466 [WARN] (src/control_connection.cpp:232:virtual void cass::ControlConnection::on_close(cass::Connection *)): Host 127.0.0.1 does not support protocol version 4. Trying protocol version 3...


It downgrades protocol version and successfully connects.


Mike




--
You received this message because you are subscribed to the Google Groups "DataStax C++ Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpp-driver-us...@lists.datastax.com.

Michael Penick

unread,
Apr 8, 2016, 6:31:02 PM4/8/16
to cpp-dri...@lists.datastax.com
Have you looked at the driver logs?

C++ driver 2.3 with Cassandra 2.1 I'm seeing the following:

1460154254.466 [WARN] (src/connection.cpp:795:void cass::Connection::notify_error(const std::string &, cass::Connection::ConnectionError)): Host 127.0.0.1 received invalid protocol response Invalid or unsupported protocol version: 4

1460154254.466 [WARN] (src/control_connection.cpp:213:virtual void cass::ControlConnection::on_close(cass::Connection *)): Lost control connection on host 127.0.0.1

1460154254.466 [WARN] (src/control_connection.cpp:232:virtual void cass::ControlConnection::on_close(cass::Connection *)): Host 127.0.0.1 does not support protocol version 4. Trying protocol version 3...


It downgrades the protocol version and successfully connects. 


Maybe there's something in the driver log that can help diagnose the issue?


Mike


On Fri, Apr 8, 2016 at 1:58 PM, Kirill Khistyaev <kir...@gmail.com> wrote:

Kirill Khistyaev

unread,
Apr 9, 2016, 12:57:55 PM4/9/16
to cpp-dri...@lists.datastax.com
Mike,
Thank you for the fast reply.
The only errors I see in the driver log is:
 [ERROR] (src/connection.cpp:817:void cass::Connection::log_error(const std::string&)): Host 10.122.71.85 had the following error on star
tup: Unable to connect
10:04:31 xapds3:1460210671.356 [ERROR] (src/connection.cpp:538:static void cass::Connection::on_connect(cass::Connector*)): Connect error 'connection refused' on host 
10.122.71.85

I don't see any warnings and I believe we haven't changed the logging level. 
What minor version of Cassandra 2.1 have you used? We use 2.1.5.
Also we are using non-standard native port for connection which we set with cass_cluster_set_port(). Not sure if that can affect anything.
I can check for more information but I even not sure what else should I check.

Thank you,
Kir

Kirill Khistyaev

unread,
Apr 11, 2016, 3:29:18 PM4/11/16
to cpp-dri...@lists.datastax.com
I tried setting version manually today with cass_cluster_set_protocol_version and when I set it to 3 everything works. But When I set it to 4 I am getting the following errors:

1460402415.464 [ERROR] (src/connection.cpp:817:void cass::Connection::log_error(const std::string&)): Host 10.122.140.20 had the following error on startup: Received error response 'io.netty.handler.codec.DecoderException: org.apache.cassandra.transport.ProtocolException: Invalid or unsupported protocol version: 4' (0x02000000)
1460402415.464 [WARN] (src/control_connection.cpp:213:virtual void cass::ControlConnection::on_close(cass::Connection*)): Lost control connection on host 10.122.140.20
1460402415.464 [ERROR] (src/connection.cpp:538:static void cass::Connection::on_connect(cass::Connector*)): Connect error 'connection refused' on host 10.122.140.84
1460402415.464 [ERROR] (src/connection.cpp:817:void cass::Connection::log_error(const std::string&)): Host 10.122.140.84 had the following error on startup: Unable to connect
1460402415.464 [WARN] (src/control_connection.cpp:213:virtual void cass::ControlConnection::on_close(cass::Connection*)): Lost control connection on host 10.122.140.84

I think I may have found the problem. Due to the bug in C* v. 2.1.5 it returns incorrect error code:
https://issues.apache.org/jira/browse/CASSANDRA-9451

Not sure if anything can be done in this case rather than manually downgrading the version.

Kirill

Kirill Khistyaev

unread,
Apr 11, 2016, 3:40:35 PM4/11/16
to cpp-dri...@lists.datastax.com
Looking at the code of Connection::StartupHandler::on_set(). Can we changed && condition to || in the following code:
if (error->code() == CQL_ERROR_PROTOCOL_ERROR &&
          error->message().find("Invalid or unsupported protocol version") != StringRef::npos)

Feels like && does a redundant check.

Kirill

Michael Penick

unread,
Apr 11, 2016, 5:25:43 PM4/11/16
to cpp-dri...@lists.datastax.com
The issue with making that "||" is CQL_ERROR_PROTOCOL_ERROR can be caused by other protocol related errors other than an unsupported protocol version. In those cases the driver doesn't attempt to recover.

Mike
Reply all
Reply to author
Forward
0 new messages