All Products
Search
Document Center

HTTPDNS:Service IP address scheduling operation

Last Updated:Oct 18, 2022

This topic describes how to call the service IP address scheduling operation in scenarios where HTTPDNS SDKs cannot be used.

Feature

Important

The operation is integrated into the official HTTPDNS SDKs. If you cannot use HTTPDNS SDKs, you can directly call the operation.

You can call this operation to obtain the optimal and latest service scheduling information based on the source IP address and more disaster recovery capabilities. The following features are provided:

  1. Queries a list of service IP addresses and allows clients to dynamically query the IP addresses of service nodes.

  2. Lists a list of all domain names that are enabled. This way, clients can avoid invalid resolution requests.

  3. Dynamically obtains the service endpoint list after a service node becomes abnormal.

Terms

Scheduling service: The operation that is used for scheduling. Service IP addresses and other service scheduling information are returned based on the source IP address.

Resolution service: The operation that is used for resolution. For more information, see the resolution service documentation.

Startup IP address: The IP address that is used to call the scheduling operation in the first startup or disaster recovery. This IP address does not provide resolution services.

Service IP address: The IP address that is used to call scheduling and resolution services.

Access method

Service IP address scheduling operation-new
  1. Submit a ticket to apply for the startup IP address list.

    Note

    The startup IP address must be written in the app. To ensure service availability, multiple startup IP addresses are provided.

  2. Use a startup IP address to call the scheduling service to obtain the list of service IP addresses.

    Note

    • The scheduling service supports HTTP and HTTPS access. For more information, see the Verify server identity section of this topic.

    • The startup IP address can be used only to call the scheduling service and does not provide the resolution service.

  3. Use the service IP address to call the resolution service.

  4. You must periodically use service IP addresses to call the scheduling service to Update the service IP address list and maintain the validity of the service IP address list.

    Note

    The service IP addresses provide both the scheduling service and the resolution service.

    • (Recommend) Update the service IP address list when a cold start is initiated

    • (Recommend) Update the service IP address list when you switch the network environment

    • (Recommend) Update the service IP address list at least once every 8 hours

  5. When all service IP addresses are unavailable, use the startup IP address to call the scheduling service and obtain the list of available service IP addresses.

  6. When all startup IP addresses are unavailable, use exponential backoff to retry updating the service IP address list.

    Important

    The service IP address list returned by the resolution service may expire. The service IP address list may change at any time.

Access method

URL: https://{Startup IP address_or_service IP address}/{account_id}/ss

Important

{account_id} specifies the exclusive ID of HTTPDNS. You can obtain it in the HTTPDNS console.

Request method: GET

The following table describes the optional parameters used to troubleshoot scheduling exceptions.

Parameter

Required

Description

sid

Optional

The session ID that is generated when the app starts and used to mark a separate app lifecycle. The session ID is in the following format: [a-zA-Z0-9]{12}

net

Optional

The network at the OS layer when a request is initiated. Valid values: 5g, 4g, 3g, 2g, wifi, and unknown.

bssid

Optional

The basic service set identifier (BSSID) of the Wi-Fi environment. BSSIDs are used to mark different Wi-Fi networks.

The following table describes the optional parameters used to select nodes outside the Chinese mainland.

Note

Parameter

Required

Description

n

Optional

The random number to be signed. The number must be a hexadecimal number and must be 8 to 16 characters in length. Example: abcdef2345.

t

Optional

The number of seconds that have elapsed since January 1, 1970. The value is a 10-bit positive integer.

Important

The offset between the client time and server time must be less than 150 seconds. You can modify the time based on the Date parameter in the response header.

s

Optional

The signature that is generated with the secret. You can view the secret in the HTTPDNS console. Calculation method: s=md5sum(n-secret-t), For example, if n=abcdef2345,secret=123456,t=1632912372, the ASCII code of "abcdef2345-123456-1632912372" is signed to be: de7be63a9f19cf11e9d455d7d4f23cb4.

region

Optional

The service node. Select a service node outside the Chinese mainland. Only the Hong Kong node and Singapore node are supported. After you specify this parameter, the local service node is returned. If you retain the default settings, the service node in the Chinese mainland is used.

Verify the server identity:

  • When you use the HTTPS request scheduling service, a valid certificate with the hostname 203.107.1.1 is provided regardless of which IP address is used. When you verify the server identity based on the certificate, ignore the hostname error in the certificate error and verify that the hostname in the certificate is 203.107.1.1.

  • When you use the HTTP request scheduling service, the response content is signed based on the following parameters, and the signature value is placed in the X-Checksum-HmacMD field of the response header due to the lack of the TLS-based security mechanism.

Sample code:

  • If the secretKey is IAmASecret, the random number n is 2EUenAaShVfy, and the current timestamp is 1568802250, the response content is {"service_ip": ["47.74.222.190"],"service_ipv6":["240b:4000:f10::178"]}

  • Request URL: http://{Start IP address_or_service IP address}/{account_id}/ss?n=2EUenAaShVfy&t=1568802250

  • sign = hmacMD5("IAmASecret", "2EUenAaShVfy-{"service_ip":["47.74.222.190"],"service_ipv6":["240b:4000:f10::178"]}-1568802250") = 3C74A498A00EEE6C5E7C599B3B882658

  • The response header must contain X-Checksum-HmacMD5:3C74A498A00EEE6C5E7C599B3B882658.

Note

To view the secretkey, go to the HTTPDNS console and choose Authentication > Secure Access with Authentication.

Sample response:

If a request is successful, the HTTP status code 200 is returned. The response is in the JSON format. Example:

{
  "service_ip": [
    "47.74.222.190"
  ],
  "service_ipv6": [
    "240b:4000:f10::178"
  ]
}

Field

Description

service_ip

The IPv4 address list. Use this IP address list to access the IPv4 link service.

service_ipv6

The IPv6 address list. Use this IP address list to access the IPv6 link service.

If a request fails, the HTTP status code 4xx or 5xx and an error code are returned. The response is in the JSON format.

{
  "code": "MissingArgument"
}

Error codes

Error code

HTTP status code

Description

MissingArgument

400

A required parameter is not specified.

TimeOutOfSync

400

The time offset is greater than or equal to 150 seconds. Modify the time based on the Date parameter in the response header.

InvalidNonce

400

The random number does not meet the requirements.

InvalidTimestamp

403

The timestamp format is invalid.

AccountNotExists

403

The account does not exist or is disabled, or the domain name is not added to the HTTPDNS console.

InternalError

500

An internal error has occurred on the server.