Troubleshooting APIs
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.
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.
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 |
Yes |
Directs the SDK's internal logs to the |
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 |
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:
-
Network connectivity failed for a single-host resolution.

-
Network connectivity failed for a batch resolution.

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

-
A signature error was reported for a batch resolution.

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

-
An encryption error was reported for a batch resolution.

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

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