突然间,我们的 Ubuntu php5.6-fpm 服务器停止处理 curl 请求。
这是我发现的:
从控制台运行时工作php test.php
。
通过潮湿的工作console wget -qO- https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4 | cat
使用 curl 从console ums-admin@svr1:/var/www/propertymonitor.ae/htdocs/v2$ curl https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4
但是通过https://example.com/test.php上的 php-fpm 调用脚本它不起作用并抱怨 DNS 查找失败?!
重新启动 php5.6-fpm 并再次开始工作?!
下面的代码:
<?php
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$data = curl_exec($ch);
if ($data === false)
{
echo 'Curl error: ' . curl_error($ch);
} else {
echo 'Response: ' . $data;
}
// close curl resource to free up system resources
curl_close($ch);
?>
系统的其余部分检查:
cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com
并且没有丢包:
64 bytes from 8.8.8.8: icmp_seq=3150 ttl=46 time=129 ms
64 bytes from 8.8.8.8: icmp_seq=3151 ttl=46 time=124 ms
64 bytes from 8.8.8.8: icmp_seq=3152 ttl=46 time=124 ms
64 bytes from 8.8.8.8: icmp_seq=3153 ttl=46 time=124 ms
^C
--- 8.8.8.8 ping statistics ---
3153 packets transmitted, 3153 received, 0% packet loss, time 3154312ms
rtt min/avg/max/mdev = 114.975/124.705/139.692/2.004 ms
见这里:https ://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1674733
更新导致了这个问题。
似乎该错误已修复并已发布。