Bug #52558 [Opn->Nab]: multi curl fails to return response, where curl does.
| From: | pierrick@php.net | Date: | Sat, 22 Dec 2012 05:26:07 +0000 |
| Subject: | Bug #52558 [Opn->Nab]: multi curl fails to return response, where curl does. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175539@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=52558&edit=1
ID: 52558
Updated by: pierrick@php.net
Reported by: malaimo at sesda2 dot com
Summary: multi curl fails to return response, where curl
does.
-Status: Open
+Status: Not a bug
Type: Bug
Package: cURL related
Operating System: linux 2.6.32-24 libcurl 7.21.0
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is not a bug, if you set the option CURLOPT_VERBOSE you'll see that for
every FTP download, curl will first attempt to use EPSV before using PASV.
That's why you've got those "couldn't connect to host".
If you add curl_setopt($ch, CURLOPT_FTP_USE_EPSV, 0) you'll not get the error
anymore.
The error returned by curl_error is not always a "fatal", so it's not because
you've got one that your call failed.
Previous Comments:
------------------------------------------------------------------------
[2011-12-29 11:34:02] jonathan dot bokobza at gmail dot com
same issue on windows 7 x64 with php 5.3.8
i think this might be related to curl version (7.22)
according to : http://curl.haxx.se/changes.html#7_23_1
a new version was released with multiples bugs fixes
------------------------------------------------------------------------
[2011-03-25 07:06:21] will at willolbrys dot com
I think I encountered the same bug here: http://stackoverflow.com/questions/4780741/php-curl-multi-getcontent-partial-body-received/5429110#5429110
reprinted for simplicity:
I encountered this bug while using the rolling-curl multicurl lib, but the underlying problem seems
to be in php itself. Here's my php -v:
PHP 5.3.3-1ubuntu9.3 with Suhosin-Patch (cli) (built: Jan 12 2011 16:07:38)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Under some circumstances (in my case CURLOPT_TIMEOUT was being maxed) curl_error and curl_errno
would not properly report an error in the curl. I had to use the 'result' key from the
array returned by curl_multi_info_read. That result code gave me the actual error number when the
curl_err* functions reported everything as normal.
------------------------------------------------------------------------
[2010-08-06 15:09:19] malaimo at sesda2 dot com
Description:
------------
When using both curl and multi_curl i get a curl_errno of 0 for each handle while an curl_error
results a string error.
When using multi_curl the error string is: Failed connect to ftp.nmh.ac.uk:21; Operation now in
progress
When using curl the error string is: couldn't connect to host
Using multi_curl results in a null body returned with curl_multi_getcontent
Using curl yields the data of the file when using curl_exec
Test script:
---------------
two scripts are below to reproduce.
# multi_curl method
<?php
$curls = array();
$cmh = curl_multi_init();
$dlFiles = array(
'ftp://ftp.nmh.ac.uk/wdc/obsdata/hourval/single_year/1914/sod1914.wdc',
'http://spc.igpp.ucla.edu/uclamag/ffi/lal/B99300_LAL.ffd',
'ftp://ftp.nmh.ac.uk/wdc/obsdata/hourval/single_year/1922/hua1922.wdc',
'http://vmo.igpp.ucla.edu/data1/Weygand/ProcessedSolarWindGSE/ACE/mag/2000/acemag200001.dat'
);
foreach ($dlFiles as $x => $file) {
$curls[$x] = curl_init();
curl_setopt($curls[$x], CURLOPT_URL, $file);
curl_setopt($curls[$x], CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curls[$x], CURLOPT_FOLLOWLOCATION, 1);
curl_multi_add_handle($cmh, $curls[$x]);
}
$active = null;
do {
$mrc = curl_multi_exec($cmh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($cmh) != -1) {
do {
$mrc = curl_multi_exec($cmh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
foreach ($dlFiles as $x => $file) {
var_dump(substr(curl_multi_getcontent($curls[$x]), 0, 10), curl_errno($curls[$x]),
curl_error($curls[$x]));
curl_multi_remove_handle($cmh, $curls[$x]);
curl_close($curls[$x]);
}
curl_multi_close($cmh);
?>
# curl method
<?php
$dlFiles = array(
'ftp://ftp.nmh.ac.uk/wdc/obsdata/hourval/single_year/1914/sod1914.wdc',
'http://spc.igpp.ucla.edu/uclamag/ffi/lal/B99300_LAL.ffd',
'ftp://ftp.nmh.ac.uk/wdc/obsdata/hourval/single_year/1922/hua1922.wdc',
'http://vmo.igpp.ucla.edu/data1/Weygand/ProcessedSolarWindGSE/ACE/mag/2000/acemag200001.dat'
);
foreach ($dlFiles as $x => $file) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
var_dump(substr(curl_exec($ch), 0, 10), curl_errno($ch), curl_error($ch));
curl_close($ch);
}
?>
Expected result:
----------------
no errors at all and multi_curl letting me get the contents of the curl.
Actual result:
--------------
multi_curl
bool(false)
int(0)
string(61) "Failed connect to ftp.nmh.ac.uk:21; Operation now in progress"
string(10) "����
int(0)
string(0) ""
bool(false)
int(0)
string(61) "Failed connect to ftp.nmh.ac.uk:21; Operation now in progress"
string(10) "01 01 2000"
int(0)
string(0) ""
for curl
string(10) "SOD1401X01"
int(0)
string(24) "couldn't connect to host"
string(10) "����
int(0)
string(0) ""
string(10) "HUA22 1D 1"
int(0)
string(24) "couldn't connect to host"
string(10) "01 01 2000"
int(0)
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=52558&edit=1