Description
Is the IP address list in an HTTPDNS resolution result sorted?
Cause
No. The IP address list that the HTTPDNS server returns is not sorted. The HTTPDNS server sends the end user's IP information to the authoritative DNS. The authoritative DNS then uses this information to perform precise scheduling and return a list of IP addresses for the nearest nodes. HTTPDNS does not sort this final list.
Solution
You can use the IP ranking API to sort the resulting IP addresses. This helps you obtain the IP address with the best connectivity. The following code provides examples:
Android:
ArrayList<IPRankingBean> list = new ArrayList<IPRankingBean>();
list.add(new IPRankingBean("www.aliyun.com", 8080));
new InitConfig.Builder().setIPRankingList(list);Note
This method was added in version 2.3.2.
iOS:
HttpDnsService *httpdns = [HttpDnsService sharedInstance];
NSDictionary *IPRankingDatasource = @{
@"www.abc.com" : @80,
@"www.cba.com" : @443,
@"www.bac.com" : @443
};
[httpdns setIPRankingDatasource:IPRankingDatasource];Harmony:
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { httpdns } from '@aliyun/httpdns';
const ACCOUNT_ID = 'Replace this with the Account ID from the Alibaba Cloud HTTPDNS console'
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
httpdns.configService(ACCOUNT_ID, {
context: this.context,
// ************* IP ranking configuration begin *************
hostConfigsForIpRanking: [{
host: 'www.aliyun.com',
port: 80
}]
// ************* IP ranking configuration end *************
})
}
// Other code is omitted
}Applies to
HTTPDNS
该文章对您有帮助吗?