The HTTPDNS mobile SDK returns an empty result during resolution

更新时间:
复制 MD 格式

Problem description

When you use the HTTPDNS mobile SDK, the resolved IP address for a domain name is empty.

Causes

This issue may be caused by the following:

  • The domain name that you want to resolve has not been added in the HTTPDNS console.

  • The custom resolution feature is enabled, but the Function Compute (FC) function for the custom scheduled domain name is not configured correctly.

  • The domain name resolution process first checks the cache. If a valid resolution result exists in the cache, the SDK immediately returns the local cache result. If no valid resolution result is available in the cache, an empty value is returned.

    Note

    When you first call the asynchronous domain name resolution API, an empty value might be returned due to latency. Call the API again to retrieve the result.

  • The pre-resolution API is enabled in the mobile client code, but the domain names in the pre-resolution list do not match the domain names in the HTTPDNS console. This causes the resolution to fail.

  • Authentication is not enabled in the mobile client code, but Signature-based Access is enabled in the HTTPDNS console. This results in a lack of permission to access the HTTPDNS API.

  • The TTL is short and the cached IP address has expired, which causes an empty result to be returned. This is normal. Call the API again to retrieve the latest IP address.

  • A configuration error occurred during the mobile SDK integration.

Solutions

Follow these steps to troubleshoot the issue:

Step 1: Use the online tool in the console to run a test

  1. Log on to the HTTPDNS console.

  2. In the navigation pane on the left, click Online Experience. Enter the domain name that you want to resolve and check if a result is returned.

    • If no result is returned, add a DNS record for the domain name in your domain name management platform. Make sure the Online Experience tool can return a resolved IP address for the domain name.

    • If a result is returned, proceed to the next step.

Step 2: Check the list of added domain names in the console

  1. Log on to the HTTPDNS console.

  2. In the navigation pane on the left, click Added Domain Names. Check if the domain name that you want to resolve is in the list of added domain names.

    • If the domain name does not exist, click Add Domain Name, enter the domain name that you want to resolve, and then click Confirm. For more information, see Add a domain name.

    • If present, you can proceed to the next troubleshooting step.

Step 3: Check if the pre-resolution API is enabled in the code

Check if the pre-resolution API is enabled in the mobile client code:

  • If it is not enabled, enable this API to obtain resolution results in advance and reduce the latency of subsequent domain name resolution requests.

  • If it is enabled, check whether the domain names in the pre-resolution list match the domain names added in the console. If they do not match, update the domain names in the list. If they match, proceed to the next step.

Step 4: Check if authentication is enabled in the client-side code

Android:

HttpDnsService httpdns = HttpDns.getService(applicationContext, accountID,secretKey);

iOS:

HttpDnsService *httpdns = [[HttpDnsService alloc] initWithAccountID:accountID secretKey];

Harmony:

httpdns.configService(accountID, {
      context: this.context,
      secretKey: this.secretKey
    });

Step 5: Check if signature-based access is enabled in the HTTPDNS console:

  • If it is not enabled, make sure that Signature-based Access is disabled in the HTTPDNS console, and then try again.

    Note

    Note: Enable signature-based access to improve security. After you enable the authentication API, enable Signature-based Access.

  • Enabled: Verifies that the secretKey in the authentication interface is correct and then proceeds to the next check.

Step 6: Perform a comparison test using the official demo

Perform a comparison test using the official demo. If the official demo can retrieve the resolved IP address correctly, check your mobile SDK integration configuration.

Step 7: Check the function configuration for the domain name in the custom resolution settings of the EMAS HTTPDNS console

To the right of the domain name, click Manage to view the configuration.

Click the name of the configured function.

Navigate to FC > Services > Functions.

Click the function name.

Configure the input parameters for the test, click Test Function, and check if the execution result is normal.

References

Applies to

  • HTTPDNS