cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

PHP CURL : Long wait time for CURL_IPRESOLVE_V6

From: Sukhbir Gill <sukhbirgs_at_gmail.com>
Date: Tue, 21 Dec 2004 11:08:32 -0700

I am having problem with CURL_IPRESOLVE_V6. It takes long time to
resolve the host and then CURL_IPRESOLVE_V4 takes over and it does it
instantaneously. My system setting are:

PHP Version 4.3.9
Fedora core 2
Curl 7.12.1

/***********************************************
PHP CODE FOR CURL SETUP

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);

        // next two lines added to make it work on certain servers
(Apache2 related?)
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Referer: " . STORE_NAME,
                                                    "Host: " . $url,
                                                   "Accept:
                                                  
image/gif,image/jpeg,image/pjpeg,text/plain,text/html,*/*",
                                                   "Pragma:",
                                                   "Content-Type:image/gif"));
                                           
         curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
          $xmlResponse = curl_exec ($ch);
         curl_close ($ch);

I tried setting CURLOPT_IPRESOLVE to CURL_IPRESOLVE_V4 but it still
tries CURL_IPRESOLVE_V6 first.
*******************************************************************/

This is the info by using curl_getinfo($ch)
/****************************************************************

Array
(
    [url] => https://www.ups.com/ups.app/xml/Rate
    [content_type] => application/xml
    [http_code] => 200
    [header_size] => 160
    [request_size] => 1825
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 34.645003
    [namelookup_time] => 34.293846
    [connect_time] => 34.335259
    [pretransfer_time] => 34.448216
    [size_upload] => 0
    [size_download] => 2458
    [speed_download] => 70
    [speed_upload] => 0
    [download_content_length] => 2458
    [upload_content_length] => 0
    [starttransfer_time] => 34.64493
    [redirect_time] => 0
)

You can see that [namelookup_time] => 34.293846 is really
long. And all that time is taken by CURL_IPRESOLVE_V6.
****************************************************************/

I am using similar code for getting information from FEDEX website
"https://gateway.fedex.com/GatewayDC" and it takes some where 0.80 sec
to 1.10 secods.

My question is "Can i some how dissable CURL_IPRESOLVE_V6 and just use
CURL_IPRESOLVE_V4. I did tried it in my php code but its not working.
".

I really appriciate any help.
Regards,
Sukhbir
Received on 2004-12-21