# Mobile Resolution HttpDNS

2.19.2

When a developer invokes wx.request , the mobile resolution HttpDNS service can be turned on. The service sends a domain name resolution request to the DNS server of the service provider based on the Http protocol, replacing the traditional way of initiating a resolution request to the carrier's Local DNS based on the DNS protocol. It can avoid the problems of domain name hijacking and cross-network access caused by Local DNS, and solve the troubles caused by domain name resolution anomalies in mobile internetworking services.

# Weixin Mini Program Instructions for developers using mobile parsing

  1. Go to WeChat Service Marketplace to purchase HttpDNS resources and get the Service ID on the Service Details page - Access Document.
  2. Weixin Mini Program Call wx.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', //仅为示例,并非真实的接口地址
  enableHttpDNS: true,
  httpDNSServiceId: 'wxa410372c837a5f26',
  success(res) {
    console.log('request success', res)
  },
  fail(res) {
    console.error('request fail', res)
  }
})

# Statement of billing

  1. The cost of using the service is billed according to the actual call to the service provider interface, the pricing strategy is established by the service provider, and developers are required to go to the WeChat service market to purchase, renew, and so on.
  2. WeChat The WeChat side caches every time the server interface is invoked on behalf of the developer, and the cache policy is determined by the TTL returned by the server, so it is not necessarily a fee to be incurred every time the request interface is invoking.
  3. Starting with the base library v2.32.1, if the developer's service availability is 0,When still declaring in the wx.request interface the use of the mobile resolution capabilities provided by the provider, local DNS resolution is used to justify it, and the httpdns unpaid error message and error code is returned in the success callback parameter exception.reasons (reasons is an array), similar to[{ "errMsg": "getDNSInfo:fail no enough httpdns quota", "errno": 602103 }]

# Note

  1. Http DNS incompatible network agents

Before the v2.22.1 release of the base library, when a device uses a network agent and enableHttpDNS is enabled, the request interface fails and the fail callback errMsg contains ERR_PROXY_CONNECTION_FAILED {"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 address this, starting with v2.22.1, the base actively forces the enableHttpDNS to shut down if a network agent is used. The wx.getNetType interface also allows developers to verify that the network agent is enabled. Use:

wx.getNetworkType({
  success(res) {
    console.log(res.hasSystemProxy) // 开启网络代理时为 true,否则为 false
  }
})
Error code Introductions
600000 Network Error
602000 Network request error
602001 A system error
602002 HTTP request httpdns server error
602101 Weixin Mini Program Not purchasing httpdns service in the service market
602102 Weixin Mini Program Expired in the httpdns service marketplace resource pack
602103 Weixin Mini Program Insufficient quota in 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 Instructions

In order to protect the security of WeChat customers, the mobile resolution service used by Weixin Mini Program needs to pass the WeChat side security certification, which can be listed in the WeChat service market after certification.

WeChat We welcome more service providers to provide mobile resolution services for Weixin Mini Program.To request access, send an email using the following template and a person will contact you.

收件人:servicemarket@tencent.com
主题:【上架服务市场】XXX(服务商)申请上架HttpDNS服务
正文:需要写明服务商的基本资料,包括不仅限于服务商名称、业务范围、技术证书、合作意向、联系方式等