Lumen httpclient 请求自己 API 超时问题!?!
IndexController.php
function test(Request $request)
{
//$uri = "http://www.baidu.com";
$uri = "http://localhost:8083/test1";
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_URL, $uri);
$res = curl_exec($curl);
//var_dump($res);
curl_close($curl);
echo $res;
}
function test1()
{
echo '111111111111111111';
}
routes/web.php
$router->get('test','Index\IndexController@test');
$router->get('test1','Index\IndexController@test1');
页面调用 http://localhost:8083/test 超时!!
不知是什么原因
把$uri改为 其他地址(例如:http://www.baidu.com )可以正常访问 ?
请问大神门这是什么原因造成的?
推荐文章: