Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Closed: Unable to decode header #49

Closed
datalatics-official opened this issue Nov 25, 2021 · 7 comments
Closed

Connection Closed: Unable to decode header #49

datalatics-official opened this issue Nov 25, 2021 · 7 comments

Comments

@datalatics-official
Copy link

datalatics-official commented Nov 25, 2021

When try to make connection with proxy service. It logs a message that "unable to decode hearder" and close the connection. Need to fix is soon. Please find the attach error's screenshot.
astra_connection_error

When we try to run it with --debug.
image

@mpenick

@mpenick
Copy link
Contributor

mpenick commented Nov 29, 2021

What driver and its version is connecting to the proxy?

@mpenick
Copy link
Contributor

mpenick commented Nov 30, 2021

It looks like you might be using java-driver 2.1.X. This isn't currently supported for a couple reasons:

  1. This is the easier problem to solve. The 2.X driver using the CQL protocol v3, and cql-proxy currently hard codes the version to v4. This small patch fixes that issue:
diff --git a/proxy.go b/proxy.go
index 5af2412..b7b073c 100644
--- a/proxy.go
+++ b/proxy.go
@@ -83,7 +83,7 @@ func main() {
 	}
 
 	p := proxy.NewProxy(ctx, proxy.Config{
-		Version:           primitive.ProtocolVersion4,
+		Version:           primitive.ProtocolVersion3,
 		Resolver:          resolver,
 		ReconnectPolicy:   proxycore.NewReconnectPolicy(),
 		NumConns:          1,

However, this is not an actual fix though. My thought is the proxy should allow clients to be connected to the backend using multiple protocol versions simultaneously. It could have a session cache for each version.

  1. The bigger problem is Astra doesn't not support the legacy schema tables that used to live under system. It's possible that the proxy could intercept these calls and do some type of conversion to/from the new schema tables under system_schema. This could be a lot of work, but maybe only a subset needs to be supported to get older drivers working properly.
Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.InvalidQueryException: table system.schema_keyspaces does not exist))
	at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:240)
	at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:86)
	at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1455)
	at com.datastax.driver.core.Cluster.init(Cluster.java:158)
	at com.datastax.driver.core.Cluster.connectAsync(Cluster.java:329)
	at com.datastax.driver.core.Cluster.connect(Cluster.java:279)
	at org.example.App.main(App.java:21)

@mpenick
Copy link
Contributor

mpenick commented Nov 30, 2021

@mpenick
Copy link
Contributor

mpenick commented Nov 30, 2021

This fixes both issues #52 enough to allow connecting older versions of drivers; however, the server/client still share the same protocol, but the proxy can support multiple protocols at one time for different client connection. For schema under system the proxy just returns empty tables which is enough to allow the driver to connect and start running queries.

@datalatics-official
Copy link
Author

What driver and its version is connecting to the proxy?

"com.datastax.cassandra" % "cassandra-driver-core" % "2.1.10.3"

@mpenick
Copy link
Contributor

mpenick commented Dec 7, 2021

Released https://github.com/datastax/cql-proxy/releases/tag/v0.0.4. Let me know if this fixes your issue.

@datalatics-official
Copy link
Author

Thank you @mpenick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants