Stream_socket_client 超时

C. *_* E. 3 php sockets stream-socket-client

我正在尝试调试 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
            );
        }
Run Code Online (Sandbox Code Playgroud)

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

And*_*kov 5

尝试检查一下allow_url_fopen

此选项启用 URL 感知的 fopen 包装器,从而能够访问 URL 对象(如文件)。

请参阅: https: //php.net/manual/en/filesystem.configuration.php