I have a very simple snippet of code:
<?php
$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
fwrite($fp, "writing works..\n");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://10.0.0.1/url");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
print_r(curl_exec($ch));
print_r(curl_errno($ch));
print_r(curl_getinfo($ch));
print_r(curl_version());
curl_close($ch);
fclose($fp);
?>
Which works fine in general, but it is currently broken in a particular environment I'm using. curl_errno
returns 2
, i.e. CURLE_FAILED_INIT
.
I'm trying to investigate whether there are system issues here, but I would like to know if there is some way I can debug code-wise what's the issue.
Answers like the ones in this question do not yield any output (file errorlog.txt
is simple found empty.. which is expected I guess since libcurl can't even initialize).
The output of curl_getinfo()
is just useless since it never gets to do the request. This is the curl_version output:
[version_number] => 466176
[age] => 3
[features] => 558781
[ssl_version_number] => 0
[version] => 7.29.0
[host] => x86_64-redhat-linux-gnu
[ssl_version] => NSS/3.28.4
[libz_version] => 1.2.7
[protocols] => Array
(
[0] => dict
[1] => file
[2] => ftp
[3] => ftps
[4] => gopher
[5] => http
[6] => https
[7] => imap
[8] => imaps
[9] => ldap
[10] => ldaps
[11] => pop3
[12] => pop3s
[13] => rtsp
[14] => scp
[15] => sftp
[16] => smtp
[17] => smtps
[18] => telnet
[19] => tftp
)
Anyone has any pointers?
Thanks