# Mobile Resolution HttpDNS
From the base library 2.19.2 Start support
Developer callswx.requestYou can turn on the mobile resolution HttpDNS service. The service sends a domain name resolution request to the DNS server of the service provider based on the Http protocol, instead of sending a domain name resolution request to the carrier based on the DNS protocol. The traditional way for DNS to initiate resolution requests, avoiding Local Domain name hijacking and cross-network access problems caused by DNS, to solve the problems caused by abnormal domain name resolution in the transfer of mutual networking services.
# Mini Program developers use mobile parsing instructions
- Go to[WeChat Service Market](https://fuwu.weixin.qq .com /service/detail/00022476b70ac08df25cfcefc57015)Choose HttpDNS Resources and get the Service on the Service Details page - Access Document ID。
- Mini Program callwx.request, set the enableHttpDNS parameter to true, and fill in the httpDNSServiceId parameter with the selected provider Service ID。
# Code Examples
wx.request({
url: 'example.php', //Examples only, not real interface address
enableHttpDNS: true,
httpDNSServiceId: 'wxa410372c837a5f26',
success(res) {
console.log('request success', res)
},
fail(res) {
console.error('request fail', res)
}
})
# Billing Instructions
- The fees generated by the use of the service will be charged according to the actual call service provider interface, the pricing strategy is formulated by the service provider, and the developer needs to go to the WeChat service market to purchase, renew and other operations.
- Each time the WeChat side calls the service provider interface on behalf of the developer, the WeChat side will cache, and the cache policy is determined by the ttl returned by the service provider, so it is not necessary to incur costs every time the request interface is called.
- From the base library v2.32.1 Initially, if the developer's service is available at 0, and still declares in the wx.request interface to use the mobile resolution capabilities provided by the service provider, it will use the localDNS Analysis to the bottom, and in success Callback parameter exception.reasons ( reasons Is an array.) In return httpdns Default error messages and error codes, similar to
[{ "errMsg": getDNSInfo:fail no enough httpdns quota", "errno": 602103 }]
。
# Note
- HttpDNS Incompatible network agent
In the base library v2.22.1 When a user device uses a network agent and simultaneously turns on the enableHttpDNS When, request The interface will call failure, fail Callback errMsg Will contain ERR_PROXY_CONNECTION_FAILED
Words, such as
{"errno":600001,"errMsg":"request:fail -130:net:ERR _PROXY_CONNECTION_FAILED " }
or
{"errno":600001,"errMsg":"request:fail errcode:-130 Cronet _error_code:-130 error_msg:net::ERR_PROXY_CONNECTION_FAILED " }
。
To solve this problem, from the base library v2.22.1 In the beginning, if you use a network agent, the base library automatically forces you to shut down enableHttpDNS。 Developers can also use wx.getNetworkType Interface to verify that the user has turned on the network agent. Usage:
wx.getNetworkType({
success(res) {
console.log(res.hasSystemProxy) // When the network agent is turned on True, otherwise false
}
})
# HttpDNS Related error code
Error code | Introductions |
---|---|
600000 | Network error |
602000 | Network Request Error |
602001 | System error |
602002 | HTTP request httpdns server error |
602101 | Mini Programs do not buy httpdns services in the service market |
602102 | Mini Programs in httpdns service market resource pack expired |
602103 | Mini Program is insufficient in the httpdns service market |
602104 | The httpdns provider returned an empty result |
602105 | Calling httpdns provider results in timeout |
602106 | HTTPDNS provider returns data illegally |
602107 | The result is empty. |
602108 | Unsupported httpdns provider id |
# Mobile Resolution Service Provider Access Dxplaination
In order to protect the security of the WeChat client, the mobile analysis service used by the mini program needs to pass the WeChat side security certification, and after certification, it can be placed on the WeChat service market.
WeChat side welcomes more service providers to provide mobile parsing services for Mini programs. Apply for access by sending an email to the following template and we will contact you.
收件人:servicemarket@tencent.com
Subject: [Listing Service Market] XXX (Service Provider) Application for HttpDNS Service
Need to specify the basic information of the service provider, including not limited to the service provider name, business scope, technical certificate, cooperation intention, contact information, etc.