最近微信小游戏服务器接口api.weixin.qq.com、api.mch.weixin.qq.com经常出现无法连接的问题443 failed (101: Network is unreachable),traceroute结果路由级数也不高,我们用的腾讯云服务器。

开始以为是因为10月份腾讯那百年更换域名ip导致的,以为是腾讯那边的问题,后来发现这个无法连接的域名ip是ipv6格式的,看微信官方文档是只支持ipv4并不支持ipv6的,再查了下nginx的官方文档:

Syntax:resolver address ... [valid=time] [ipv6=on|off] [status_zone=zone];
Default:
Context:httpserverlocation

Configures name servers used to resolve names of upstream servers into addresses, for example:

resolver 127.0.0.1 [::1]:5353;

The address can be specified as a domain name or IP address, with an optional port (1.3.1, 1.2.2). If port is not specified, the port 53 is used. Name servers are queried in a round-robin fashion.

Before version 1.1.7, only a single name server could be configured. Specifying name servers using IPv6 addresses is supported starting from versions 1.3.1 and 1.2.2.

 

By default, nginx will look up both IPv4 and IPv6 addresses while resolving. If looking up of IPv6 addresses is not desired, the ipv6=off parameter can be specified.

1.3.1之后支持IPV6,且默认同时开启了IPV4和IPV6,所以,这里需要关闭IPV6才能避免连接到IPV6。具体resolver配置类似如下

resolver 127.0.0.1  valid=60s ipv6=off;

Logo

鸿蒙生态一站式服务平台。

更多推荐