【问题标题】:KsqlClientException: Received 401 response from server: Unauthorized. Error code: 40100KsqlClientException:收到来自服务器的 401 响应:未经授权。错误代码:40100
【发布时间】:2022-03-16 00:43:30
【问题描述】:

尝试连接到 Confluent 托管的 KSQL 数据库。

    String username = API_KEY;      
    String password = API_SECRET;
    
    String CONFLUENT_CLOUD_HOST = "pksqlc-xxxxx.us-east-2.aws.confluent.cloud";
    
    ClientOptions options = ClientOptions.create()
            .setHost(CONFLUENT_CLOUD_HOST)
            .setPort(443)
            .setBasicAuthCredentials(username, password)
            .setUseTls(true)
            .setUseAlpn(true)
            ;
    Client client = Client.create(options);

    List<StreamInfo> streams = client.listStreams().get();

我在client.listStreams().get() 期间遇到异常:

Exception in thread "main" java.util.concurrent.ExecutionException: io.confluent.ksql.api.client.exception.KsqlClientException: Received 401 response from server: Unauthorized. Error code: 40100
   at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
   at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)

我在这里错过了什么?

【问题讨论】:

  • 你是怎么解决这个问题的

标签: java apache-kafka confluent-platform ksqldb


【解决方案1】:

您是否检查了 Confluent Cloud 集群上的 API_KEY/API_SECRET 以查看它是否被授予访问 KSQLDB 的权限?

【讨论】:

  • 你说得对,API_KEY/API_SECRET 有问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-11
  • 1970-01-01
  • 1970-01-01
  • 2017-02-23
  • 1970-01-01
  • 2012-04-29
相关资源
最近更新 更多