问题描述:
内网服务器188.188.28.158,前置机服务器172.18.163.174,前置到互联网中间还有一个网闸172.168.200.10;现在通过curl --proxy 172.168.100.60:80 -G "https://api.weixin.qq.com/cgi-bin/media/get/jssdk?access_token=ACCESS_TOKEN&media_id=MEDIA_ID"都是成功的,而 curl -x 172.18.163.174:80 https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx -H ' Authorization: WECHATPAY2-SHA256-RSA2048 mchid="190xxx91", nonce_str="593xxx242", signature="uOVRnAxxxxxw==",timestamp="15xxxx460",serial_no="1DDE5xxxxx73A8C"'
其中172.18.163.174:80为前置机ip和端口,请求5次,有3次报错 curl:(56) Received HTTP code 502 from proxy after CONNECT,排查前置机的ng日志也发现错误:443 failed (101: Network is unreachable) while connecting to upstream,client:172.168.200.10
查询网上资料,由于当前互联网对IPv6支持不完整,导致在DNS解析时通常会碰到超时问题
处理:禁用ipv6,resolver 114.114.114.114 valid=60s ipv6=off; (其中114.114.114.114为dns域名解析器ip)
最终问题解决,curl微信支付相关接口100%成功。
参考资料:
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_2&index=3