curl slow connect_time

后端 未结 2 1475
时光取名叫无心
时光取名叫无心 2021-02-09 18:30

Consider this code in a php file on my VPS server:



        
相关标签:
2条回答
  • 2021-02-09 18:52

    Try:

    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); 
    

    The above will prevent cURL from trying IPv6 first.

    0 讨论(0)
  • 2021-02-09 19:04

    I just ran the same configuration you gave and got the following:

    array
      'url' => string 'http://www.google.com' (length=21)
      'content_type' => string 'text/html; charset=UTF-8' (length=24)
      'http_code' => int 200
      'header_size' => int 2079
      'request_size' => int 151
      'filetime' => int -1
      'ssl_verify_result' => int 0
      'redirect_count' => int 0
      'total_time' => float 0.281
      'namelookup_time' => float 0
      'connect_time' => float 0
      'pretransfer_time' => float 0
      'size_upload' => float 0
      'size_download' => float 23168
      'speed_download' => float 82448
      'speed_upload' => float 0
      'download_content_length' => float -1
      'upload_content_length' => float 0
      'starttransfer_time' => float 0.187
      'redirect_time' => float 0
      'certinfo' => 
      array
        empty
      'redirect_url' => string '' (length=0)
    

    My guess is that your server connection itself might be having bandwidth issues and/or being taxed somehow by another process.

    0 讨论(0)
提交回复
热议问题