突然之间,我们的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
通过湿式工作console wget -qO- https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4 | cat
console wget -qO- https://maps.google.com/maps/api/geocode/json?address=Brooklyn+NY+USA&key=AIzaSyBGgTVnShML1_WHJL0rOTEnt2XOrgVgnu4 | cat
从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
使用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
更新导致了这个问题。
看来这个bug是固定的和释放的。