WASD42
WASD42

Reputation: 2379

Connection problems with cURL in PHP

Good day,

I have a web service that makes multiple cURL requests via PHP to different external APIs including panoramio.com, flickr.com, worldweatheronline.com, etc. Everything worked well for a year or so but few weeks ago the percent of failed connections went through the sky on some hosts (panoramio.com and worldweatheronline.com are among the leaders with total 6% of failed requests each). Immediate consequent request to the same host can be successful or failed with the same probability.

So I trying to figure out what happened and how should I fixed, maybe some system update or newer PHP version are broken...

Ubuntu 12.04.4 LTS, PHP 5.5.16 with cURL 7.22.0 (php-fpm) on nginx.

cURL options are: connection timeout 5 seconds, total timeout 60 seconds, SSL verify host and peer are both disabled, IP resolve forced to IPv4. Here are some debug information of failed requests:

[url] => http://www.panoramio.com/map/get_panoramas.php?set=public&order=popularity&from=0&to=21&size=medium&minx=82.685329&miny=25.748195&maxx=82.695311&maxy=25.757185
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 5.004513
    [namelookup_time] => 3.1E-5
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 173.194.71.141
    [certinfo] => Array
        (
        )

    [primary_port] => 80
    [local_ip] => 
    [local_port] => 0
)

Or:

(
    [url] => http://api.worldweatheronline.com/free/v1/weather.ashx?key=API_KEY_REMOVED&format=js&q=38.25000,20.60000&num_of_days=7
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 158
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 67.623743
    [namelookup_time] => 2.4E-5
    [connect_time] => 1.15904
    [pretransfer_time] => 1.159041
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => 0
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 46.37.171.96
    [certinfo] => Array
        (
        )

    [primary_port] => 80
    [local_ip] => IP_REMOVED
    [local_port] => PORT_REMOVED
)

As you can see connection process is terminated in different states but DNS name is always resolved correctly.

Any ideas how to debug and/or solve this issue will be really appreciated as I don't know where to dig anymore :/

Upvotes: 0

Views: 355

Answers (0)

Related Questions