apache-kafka KsqlClient异常错误:从服务器收到401响应:未授权,错误代码:40100

e5nszbig  于 2022-11-01  发布在  Apache
关注(0)|答案(1)|浏览(230)

正在尝试连接到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)

我错过了什么?

tjvv9vkg

tjvv9vkg1#

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

相关问题