服务器无法连接paypal.com/api.paypal.com:超时问题及解决方法
问题现象
执行以下任一命令均返回连接超时:
openssl s_client -connect api.paypal.com:443curl https://api.paypal.comping api.paypal.com
示例错误输出:
curl api.paypal.com
curl: (28) Failed to connect to api.paypal.com port 80 after 130579 ms: Connection timed out
已尝试的排查操作
- 更新系统及
ca-certificates组件 - 将DNS服务器改为
8.8.8.8 - 关闭ufw防火墙
执行traceroute paypal.com的结果:
traceroute to 64.4.250.36 (64.4.250.36), 30 hops max, 60 byte packets
1 _gateway (172.31.1.1) 4.943 ms 4.826 ms 4.807 ms
2 24156.your-cloud.host (65.108.118.147) 1.031 ms 1.080 ms 1.067 ms
3 * * *
4 * * *
5 core32.hel1.hetzner.com (88.198.249.93) 1.546 ms core31.hel1.hetzner.com (88.198.249.89) 1.526 ms core32.hel1.hetzner.com (88.198.249.93) 1.511 ms
6 core53.sto.hetzner.com (213.239.254.62) 7.752 ms core52.sto.hetzner.com (213.239.254.58) 7.119 ms 7.070 ms
7 core3.sto.hetzner.com (213.239.252.66) 7.056 ms core3.sto.hetzner.com (213.239.252.74) 6.836 ms core3.sto.hetzner.com (213.239.252.66) 6.794 ms
8 netnod-ix-ge-b-sth-4470.f5.com (195.69.119.96) 10.016 ms netnod-ix-ge-a-sth-1500.f5.com (194.68.123.96) 23.177 ms netnod-ix-ge-b-sth-1500.f5.com (194.68.128.96) 23.142 ms
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
解决方案
将请求地址从api.paypal.com替换为api-m.paypal.com。api-m.paypal.com是PayPal提供的优化版CDN节点,专门适配PayPal REST API,能有效解决部分网络环境下的连接超时问题。该方案来自WooCommerce PayPal支付插件的相关问题讨论。
内容的提问来源于stack exchange,提问作者Gal Podlipnik

