stream_socket_client time out



我试图调试PHP函数stream_socket_client,但我真的不知道如何。这是我遇到麻烦的代码:

        $this->socket = @stream_socket_client(
            $remote, $errno, $errstr,
            $this->request->getConfig('connect_timeout'),
            STREAM_CLIENT_CONNECT, $context
        );
        if (!$this->socket) {
            throw new HTTP_Request2_ConnectionException(
                "Unable to connect to {$remote}. Error: {$errstr}",
                0, $errno
            );
        }

抛出异常,错误为"无法连接到tcp://www.dropbox.com:80"。错误:"连接超时"。这段代码来自一个非常流行的Wordpress插件,它已经经过了很好的测试。我正在工作的服务器有一些怪癖,例如我被允许通过PHP上传或删除文件等,所以我想知道是否有任何PHP设置可以阻止stream_socket_client工作,以及我如何检查这些设置是为我的服务器。

尝试检查allow_url_fopen

该选项启用URL感知的fopen包装器,允许访问URL对象,如文件。

见:https://php.net/manual/en/filesystem.configuration.php

最新更新