All Products
Search
Document Center

ApsaraMQ for Kafka:Perform a health check on an ApsaraMQ for Kafka instance

Last Updated:Mar 11, 2026

If your SDK client fails to connect to an ApsaraMQ for Kafka instance, or messages cannot be sent or received, run a health check to diagnose the issue. The health check verifies network connectivity, instance availability, and client configuration in three sequential steps:

  1. Test network connectivity -- Confirm that the client can reach the instance endpoint.

  2. Test message sending -- Send a test message to verify producer functionality.

  3. Test message consumption -- Pull test messages to verify consumer functionality.

Run these tests in order. A connectivity failure causes all subsequent tests to fail.

Prerequisites

Before you begin, make sure that you have:

Placeholders

Replace the following placeholders with your actual values in all commands:

PlaceholderDescriptionExample
<endpoint>Broker endpoint of the instancealikafka-pre-cn-zv****-1-vpc.alikafka.aliyuncs.com
<topic>Name of the test topictest
<group>Name of the test consumer grouptest-group
<username>SASL usernametest
<password>SASL passwordtest****
<path-to-kafka-checker>Local directory containing KafkaChecker.jar/usr/opt/kafka-checker

Connection types

ApsaraMQ for Kafka supports three connection types. Each uses a different port and security configuration:

Connection typePortEncryptionAuthenticationFlag
VPC default9092NoneNone(none)
Internet SSL9093SSLSASL (PLAIN or SCRAM-SHA-256)-ss true
VPC SSL9094SSLSASL (PLAIN or SCRAM-SHA-256)-sp true
Note

For VPC connections (ports 9092 and 9094), the client and the instance must be in the same virtual private cloud (VPC). For differences between endpoint types, see Comparison among endpoints.

Step 1: Get the instance endpoint

  1. Log on to the ApsaraMQ for Kafka console.

  2. In the Resource Distribution section of the Overview page, select the region where the instance resides.

  3. On the Instances page, click the instance name.

  4. In the Endpoint Information section of the Instance Details page, copy the endpoint that matches your connection type.

endpoint

Step 2: Test network connectivity

  1. Navigate to the directory where KafkaChecker.jar is located:

       cd <path-to-kafka-checker>
  2. Run the telnet test. Pass the full endpoint string from the console, which includes all broker addresses with ports: Example (VPC default endpoint with three brokers):

       java -jar KafkaChecker.jar telnet -s <endpoint>
       java -jar KafkaChecker.jar telnet -s alikafka-pre-cn-zv****-1-vpc.alikafka.aliyuncs.com:9092,alikafka-pre-cn-zv****-2-vpc.alikafka.aliyuncs.com:9092,alikafka-pre-cn-zv****-3-vpc.alikafka.aliyuncs.com:9092

Interpret the results

  • Success: All brokers are reachable.

    VPC

  • Whitelist error: The endpoint whitelist is not configured for the ApsaraMQ for Kafka instance. For information about how to configure a whitelist, see Configure whitelists.

    WhiteList

Step 3: Test message sending

Important

Sending test messages generates real data. Use a dedicated test topic to avoid affecting production data.

Run the command that matches your connection type.

VPC default (port 9092)

java -jar KafkaChecker.jar send -s <endpoint>:9092 --topic <topic>

Internet SSL (port 9093)

Internet connections require Simple Authentication and Security Layer (SASL) authentication. The default SASL user uses the PLAIN mechanism. To create a SASL user with SCRAM-SHA-256, see Grant permissions to SASL users.

PLAIN mechanism:

java -jar KafkaChecker.jar send -sm PLAIN -ss true -u <username> -psw <password> -s <endpoint>:9093 --topic <topic>

SCRAM-SHA-256 mechanism:

java -jar KafkaChecker.jar send -sm SCRAM-SHA-256 -ss true -u <username> -psw <password> -s <endpoint>:9093 --topic <topic>

VPC SSL (port 9094)

PLAIN mechanism:

java -jar KafkaChecker.jar send -sm PLAIN -sp true -u <username> -psw <password> -s <endpoint>:9094 --topic <topic>

SCRAM-SHA-256 mechanism:

java -jar KafkaChecker.jar send -sm SCRAM-SHA-256 -sp true -u <username> -psw <password> -s <endpoint>:9094 --topic <topic>

Verify the result

A successful send produces output similar to the following:

result

Step 4: Test message consumption

Run the command that matches your connection type. All pull commands read up to 10 messages from partition 0, starting at offset 0.

VPC default (port 9092)

java -jar KafkaChecker.jar pull -s <endpoint>:9092 --topic <topic> --group <group> --partition 0 --offset 0 --count 10

Internet SSL (port 9093)

Note
  • If a client is connected to an ApsaraMQ for Kafka instance over the Internet, the default SASL user of the instance uses the PLAIN mechanism for authentication.

  • You can create a SASL user to perform fine-grained access control. You can specify the authentication mechanism as PLAIN or SCRAM-SHA-256. For more information, see Grant permissions to SASL users. You must run the command that corresponds to the authentication mechanism to consume messages.

PLAIN mechanism:

java -jar KafkaChecker.jar pull -sm PLAIN -ss true -u <username> -psw <password> -s <endpoint>:9093 --topic <topic> --group <group> --partition 0 --offset 0 --count 10

SCRAM-SHA-256 mechanism:

java -jar KafkaChecker.jar pull -sm SCRAM-SHA-256 -ss true -u <username> -psw <password> -s <endpoint>:9093 --topic <topic> --group <group> --partition 0 --offset 0 --count 10

VPC SSL (port 9094)

PLAIN mechanism:

java -jar KafkaChecker.jar pull -sm PLAIN -sp true -u <username> -psw <password> -s <endpoint>:9094 --topic <topic> --group <group> --partition 0 --offset 0 --count 10

SCRAM-SHA-256 mechanism:

java -jar KafkaChecker.jar pull -sm SCRAM-SHA-256 -sp true -u <username> -psw <password> -s <endpoint>:9094 --topic <topic> --group <group> --partition 0 --offset 0 --count 10

Verify the result

A successful pull produces output similar to the following:

consumer

See also