我在发出http GET请求时遇到超时错误

时间:2022-10-14 17:10:47

I am using REQUEST libary(https://github.com/rmccue/Requests) for php to make the http request and getting timeout error all the time . How can i solve this problem? This is small piece of my code:

我使用REQUEST libary(https://github.com/rmccue/Requests)为php发出http请求并一直收到超时错误。我怎么解决这个问题?这是我的一小段代码:

 $response = Requests::get($link,
            array(
                'Accept'=>'application/json',
                'Accept-Charset'=>'utf-8',
                "Connection"=> "keep-alive",
            ));

Error :

错误:

cURL error 28: Operation timed out after 10335 milliseconds with 0 out of -1 bytes received

cURL错误28:操作在10335毫秒后超时,接收到0个-1字节

1 个解决方案

#1


1  

try this

尝试这个

$response = Requests::get($link,
        array(
            'Accept'=>'application/json',
            'Accept-Charset'=>'utf-8',
            "Connection"=> "keep-alive",
        ),array('timeout'=>0));

worked for me. Happy Coding :)

为我工作。快乐编码:)

#1


1  

try this

尝试这个

$response = Requests::get($link,
        array(
            'Accept'=>'application/json',
            'Accept-Charset'=>'utf-8',
            "Connection"=> "keep-alive",
        ),array('timeout'=>0));

worked for me. Happy Coding :)

为我工作。快乐编码:)