Troubleshooting APIs

更新时间:
复制 MD 格式

Get the session ID

Obtain the session ID to trace the DNS resolution process. If a resolution error occurs, provide this ID when requesting technical support through a DingTalk group or a ticket.

Note

The session ID is a randomly generated 12-character string that remains unchanged during the app lifecycle.

getSessionId

API definition

String getSessionId()

Version introduced

1.3.2

Class

HttpDnsService

Return value

Type

Description

String

Returns the session ID.

Code example

val httpdns = HttpDns.getService(accountID)
val sessionId = httpdns?.getSessionId()
HttpDnsService httpdns = HttpDns.getService(accountID);
String sessionId = httpdns.getSessionId();

Enable HTTPDNS log printing

Enable or disable HTTPDNS debug log printing to the console. This feature is disabled by default.

Important

To prevent leakage of sensitive parameters such as accountID and secretKey, or data generated during app runtime, disable log printing in the production version.

enable

API definition

void enable(boolean enable)

Version introduced

2.0.2

Class

HttpDnsLog

Parameters

Parameter

Type

Required

Description

enable

boolean

Yes

Specifies whether to print logs to logcat.

Code example

HttpDnsLog.enable(shouldPrintLog)
HttpDnsLog.enable(shouldPrintLog);

Set a callback class for SDK logs

Set a callback class to capture internal logs from the SDK.

setLevelLogger

Adds a log callback class.

API definition

void setLevelLogger(HttpDnsLogger logger)

Version introduced

2.6.9

Class

HttpDnsLog

Parameters

Parameter

Type

Required

Description

logger

HttpDnsLogger

Yes

Directs the SDK's internal logs to the HttpDnsLogger interface via a callback, giving you control over how logs are printed and stored.

Code example

HttpDnsLog.setLevelLogger { level, s ->
    Log.println(level, "HttpDnsSDK", "resultILogger:$s")
}
HttpDnsLog.setLevelLogger(new HttpDnsLogger() {
    @Override
    public void log(int level, String s) {
        Log.println(level, "HttpDnsSDK", "resultILogger:" + s);
    }
});

removeLevelLogger

Removes a log callback class.

API definition

void removeLevelLogger(HttpDnsLogger logger)

Version introduced

2.6.9

Class

HttpDnsLog

Parameters

Parameter

Type

Required

Description

logger

HttpDnsLogger

Yes

The logger that was previously added.

Code example

HttpDnsLog.removeLevelLogger(logger)
HttpDnsLog.removeLevelLogger(logger);

Troubleshoot parsing failures with logs

If DNS resolution fails, filter for "RESOLVE FAIL" in the console to identify the cause.

If the resolution API reports an error, the following logs are output:

  1. Network connectivity failed for a single-host resolution.

76BE3851-990E-4CC6-A812-3BFDA358D3A0

  1. Network connectivity failed for a batch resolution.

DC58501C-9F5E-4088-A9B2-5E135982A74D

  1. A signature error was reported for a single-host resolution.

B5CF3EB1-2157-4F4E-A9A4-16ACE5DCC231

  1. A signature error was reported for a batch resolution.

F3B10F07-9EB6-469C-A5B6-C1B078F46D04

  1. An encryption error was reported for a single-host resolution.

6167D44B-E9F5-4A26-A8C8-56C5672F2F69

  1. An encryption error was reported for a batch resolution.

A6F5B59D-809F-4CB6-BF27-0229216A6B3A

  1. The log indicates the reason for an empty resolution result.

E95977FE-B0BC-4E24-AC3A-430B4AB9F5F5

Note

The preceding logs show only some of the reasons for resolution failures. Additional failure logs appear when you filter for "RESOLVE FAIL".