简体   繁体   English

CURL取消请求,不给出任何响应

[英]CURL canceling request, Does not giving any response

I am using angular 1. I am getting data with angular get from back end. 我正在使用angular1。我正在从后端使用angular get获取数据。 My back end function have CURL request which is fetching data from 3rd party server. 我的后端功能有CURL请求,该请求正在从第三方服务器获取数据。

In some scenarios it fetches the data ie When third party server respond with in 10 to 20 seconds. 在某些情况下,它会获取数据,即第三方服务器在10到20秒内响应。

The issue is when third party server take 30 seconds or above time. 问题是第三方服务器花费30秒或以上的时间。 It automatically cancel the request.Image is attached. 它会自动取消请求。 取消要求图片

I have also increased the Curl timeout and connection timeout options. 我还增加了“卷曲超时”和“连接超时”选项。 But it doesn't work. 但这是行不通的。

here is my code look like 这是我的代码看起来像

curl_setopt_array($curl, array(
            CURLOPT_URL => $radius_url,
            CURLOPT_CUSTOMREQUEST => "GET",
            CURLOPT_HTTPHEADER => array(
                "content-type: application/json",
            ),
            CURLOPT_HEADER => 0,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 60,
            CURLOPT_CONNECTTIMEOUT => 60,
        ));

In case of issue it does not even allow to code below that curl request to run. 如果出现问题,它甚至不允许运行该curl请求以下的代码。 It does not printing any thing below this request in case of issue. 如果出现问题,它不会在此请求下打印任何内容。

I am using CodeIgniter framework. 我正在使用CodeIgniter框架。

Set your servers timeout limit to 将您的服务器超时限制设置为

 set_time_limit(0);

If its still continues there may be a time out in the service's server. 如果仍然持续,则该服务的服务器可能已超时。 You can contact their support. 您可以联系他们的支持。

It look like php timeout 它看起来像PHP超时

you have two solution. 您有两种解决方案。

It's all the time to improve the execution time of PHP 一直在缩短PHP的执行时间

one. 一。

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time=30

change max_execution_time too large 更改max_execution_time太大

and two. 和两个。

you add first code 您添加第一个代码

set_time_limit(0) set_time_limit(0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM