Jump to content

Archived

This topic is now archived and is closed to further replies.

freedbill

Curl access to alternate port

Recommended Posts

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

Share this post


Link to post
Share on other sites

I have added a trailing slash to all three tests and get the same (nothing) results.

 

Bill

Share this post


Link to post
Share on other sites

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 <?).

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Strange. It should at least output something if there aren't any errors. You're sure cURL is installed, enabled and working?

Share this post


Link to post
Share on other sites

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.

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Yes, I've tried a single instance and a single test.  Same results.  Hopefully this all makes sense to someone.

 

Bill

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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);

 

?>

 

 

Share this post


Link to post
Share on other sites

Could someone with Godaddy hosting please try the original test script (1st post in this string), and post the results.

 

Many thanks.

 

Bill

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.