freedbill Posted June 19, 2009 Share Posted June 19, 2009 my environment: LINUX 2.6.9 Fedora Core 7 Apache 2.2 PHP 5.2.6 I am having difficulty using CURL to access a remote server on a non-standard port. Example: The url (http://socket.carfax.com:8080) should should return the following: "901 Transaction Error". Type it into a browser address window and it returns the desired result. The following php script attempts to do the same via CURL, three different ways. All return the same result....nothing.... <? $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, "http://socket.carfax.com"); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PORT, '8080'); $res = curl_exec($ch); curl_close ($ch); echo ("<br>results of test #1=$res"); $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, "http://socket.carfax.com"); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PORT,8080); $res = curl_exec($ch); curl_close ($ch); echo ("<br>results of test #2=$res"); $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, "http://socket.carfax.com:8080"); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $res = curl_exec($ch); curl_close ($ch); echo ("<br>results of test #3=$res"); ?> Does anyone have any suggestions what I am doing wrong. I'm not very familar with CURL but it appears quiet straightforward. Thanks in advance. Bill Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/ Share on other sites More sharing options...
freedbill Posted June 19, 2009 Author Share Posted June 19, 2009 I have added a trailing slash to all three tests and get the same (nothing) results. Bill Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859837 Share on other sites More sharing options...
thebadbad Posted June 19, 2009 Share Posted June 19, 2009 My output of your script is <br>results of test #1=901 Transaction Error.<br>results of test #2=901 Transaction Error.<br>results of test #3=901 Transaction Error. Seems right? If you get no output at all, there must be an error. Try to put this at the top of the script, to display errors and notices/warnings: error_reporting(E_ALL); ini_set('display_errors', 'On'); And it's recommended to use full opening tags (<?php instead of <?). Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859870 Share on other sites More sharing options...
freedbill Posted June 19, 2009 Author Share Posted June 19, 2009 I made both of your recommended modifications and still received the same results. (nothing). Am I encountering a LINUX or Apache or php configuration issue? Thank you so much for your response. Bill Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859875 Share on other sites More sharing options...
thebadbad Posted June 19, 2009 Share Posted June 19, 2009 Strange. It should at least output something if there aren't any errors. You're sure cURL is installed, enabled and working? Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859884 Share on other sites More sharing options...
freedbill Posted June 19, 2009 Author Share Posted June 19, 2009 Yes. I use it for some other functionality. BTW. The output that you received is correct. That is very encouriging, so I'm having another issue. I'm running on a leased godaddy virtual dedicated server and have complete control of my environment. I'm just not very knowledgeable when it comes to configuration of Linux or PHP. Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859902 Share on other sites More sharing options...
thebadbad Posted June 19, 2009 Share Posted June 19, 2009 I'm just not very knowledgeable when it comes to configuration of Linux or PHP. Me neither. Have you tried with only one instance of cURL? Instead of running it three times. Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859915 Share on other sites More sharing options...
freedbill Posted June 20, 2009 Author Share Posted June 20, 2009 Yes, I've tried a single instance and a single test. Same results. Hopefully this all makes sense to someone. Bill Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859930 Share on other sites More sharing options...
freedbill Posted June 20, 2009 Author Share Posted June 20, 2009 Could you do a "phpinfo(INFO_MODULES)" and let me know what version of CURL that is installed on your server. My version is 7.16.14. I see that the most recent version is 7.19.5. Doubt if this is the problem but would be interested in knowing your results. Thanks Bill Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-859954 Share on other sites More sharing options...
thebadbad Posted June 20, 2009 Share Posted June 20, 2009 My local server (PHP 5.2.6, Apache 2.2.9, Windows Vista SP1) has libcurl/7.16.0 OpenSSL/0.9.8i zlib/1.2.3. I also successfully tested the script on my hosted server (PHP 5.2.2, Apache 1.3.37, Linux) with libcurl/7.15.3 OpenSSL/0.9.6b zlib/1.2.3. Can you post a cURL script that works on your system? Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-860067 Share on other sites More sharing options...
freedbill Posted June 20, 2009 Author Share Posted June 20, 2009 Thanks for the version info. The following script works fine. <?php error_reporting(E_ALL); ini_set('display_errors', 'On'); $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, "http://www.google.com/"); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $res = curl_exec($ch); curl_close ($ch); echo ($res); ?> Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-860105 Share on other sites More sharing options...
freedbill Posted June 21, 2009 Author Share Posted June 21, 2009 Could someone with Godaddy hosting please try the original test script (1st post in this string), and post the results. Many thanks. Bill Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-860576 Share on other sites More sharing options...
freedbill Posted June 28, 2009 Author Share Posted June 28, 2009 Resolved - Godaddy blocks port 8080...even on leased servers. Thought I had complete control of my leased server, guess that is just not the case. Quote Link to comment https://forums.phpfreaks.com/topic/162961-curl-access-to-alternate-port/#findComment-864996 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.