上一篇文章《Nginx下,请求本机另外Host很慢》中,到最后仍是“通讯失败”,不过跟踪ucenter的代码,在uc_server/model/misc.php的dfopen()函数中,有以下代码:php
if(!$fp = @fsocketopen(($scheme == 'https' ? 'ssl' : $scheme).'://'.($scheme == 'https' ? $host : ($ip ? $ip : $host)), $port, $errno, $errstr, $timeout)) { |
在if条件内设置断点,即调用fsocketopen()函数失败的时候,此时查看$errstr变量的内容,其值以下:ide
Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?函数
查看fsocketopen函数的代码:post
function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) { |
发现其是调用的fsockopen()函数失败,在网上查找,发现大多数都是说fsockopen()函数不支持“http://”这样的host前缀,要直接用网址,相似www.163.com,或者localhost这样的。orm
按照网上的说法,我临时修改代码以下:server
if(!$fp = @fsocketopen('localhost', $port, $errno, $errstr, $timeout)) { |
暂时直接将第一个参数固定为localhost,从新刷新页面,终于通讯成功:ip
知道了真正缘由,将上述的临时代码用正确的方式修改就很简单了,这里就不浪费笔墨了。