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

How to connect to clickhouse through clickhouse-grpc-client? #1300

Closed
GerryYuan opened this issue Mar 25, 2023 · 4 comments
Closed

How to connect to clickhouse through clickhouse-grpc-client? #1300

GerryYuan opened this issue Mar 25, 2023 · 4 comments
Labels

Comments

@GerryYuan
Copy link

clickhouse-grpc-client use grpc protocol, JDK11, then throw ClickHouseException, why?

<dependency>
      <groupId>com.clickhouse</groupId>
      <artifactId>clickhouse-grpc-client</artifactId>
      <version>0.4.2</version>
</dependency>
final ClickHouseNode server = ClickHouseNode.builder().host("127.0.0.1").port(ClickHouseProtocol.GRPC)
            .credentials(ClickHouseCredentials.fromUserAndPassword(config.getUser(), config.getPassword())).build();
final ClickHouseClient client = ClickHouseClient.newInstance(server.getProtocol());
            this.request = client.read(server).compressServerResponse(false).decompressClientRequest(false);
client.query("drop table if exists java_client_example_table").execute().get()

throw ClickHouseException

Caused by: com.clickhouse.client.ClickHouseException: UNAVAILABLE: Network closed for unknown reason, server ClickHouseNode [uri=grpc://127.0.0.1:9100/default]@334622429
	at com.clickhouse.client.ClickHouseException.of(ClickHouseException.java:168)
	at com.clickhouse.client.grpc.ClickHouseGrpcClientImpl.sendAsync(ClickHouseGrpcClientImpl.java:346)
	at com.clickhouse.client.AbstractClient.lambda$execute$0(AbstractClient.java:273)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: Network closed for unknown reason
	at io.grpc.Status.asRuntimeException(Status.java:539)
	at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:487)
	at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489)
	at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453)
	at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486)
	at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:576)
	at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
	at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:757)
	at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:736)
	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
	... 3 more
@GerryYuan GerryYuan added the bug label Mar 25, 2023
@GerryYuan GerryYuan changed the title How to connect to clickhouse cluster through clickhouse-grpc-client? #1295 How to connect to clickhouse through clickhouse-grpc-client? #1295 Mar 25, 2023
@GerryYuan
Copy link
Author

image

DBMS: ClickHouse (ver. 23.2.4.12)
Case sensitivity: plain=exact, delimited=exact
Driver: ClickHouse JDBC Driver (ver. 0.4.0 (revision: 3a53cf1), JDBC4.2)

@GerryYuan GerryYuan changed the title How to connect to clickhouse through clickhouse-grpc-client? #1295 How to connect to clickhouse through clickhouse-grpc-client? Mar 25, 2023
@zhicwu
Copy link
Contributor

zhicwu commented Mar 26, 2023

Hi @GerryYuan, did you see any error on server? gRPC is experimental and not suitable for production. It's reserved only for testing purpose and I'll drop it someday.

@GerryYuan
Copy link
Author

Hi @GerryYuan, did you see any error on server? gRPC is experimental and not suitable for production. It's reserved only for testing purpose and I'll drop it someday.

There is no error message on the server. It feels that the server does not retain the data that accepts this port when it starts. If grpc-client is not recommended, which effective method is recommended to help me operate ck?

@zhicwu
Copy link
Contributor

zhicwu commented Mar 29, 2023

If grpc-client is not recommended, which effective method is recommended to help me operate ck?

I think it's better to start with JDBC driver. In the case you need to use Java client, it's better to stay with http protocol for now. For details, please refer to examples at here.

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

No branches or pull requests

2 participants