3

This is a problem using PHP with Curl (on hosted server). I am trying to control a remote device (LED state) on port 54512 (for example). The $url includes the IP:port number concatenated with a short CGI command.

The following is a code fragment;

$sensorIP = "77.134.85.187:54512"; // IP:port format

$url = $sensorIP . "/setParam.cgi?DOStatus_02=0" ; // set E2210 LED off

echo $url; // 

$result =  accessURL ($url); // set LED state on E2210 remote unit  

This code times out. When I use the $url as an address in a web browser it works fine. So the receiving port 54512 is not blocked. When I use IP:80 to form $url it works fine (receiving port set to 80).I tried using the CURLOPT_PORT option and the PHP script still times out.

The sending server outgoing HTTP is NOT blocking any port numbers, I checked with my hosting company. They believe I have a programming error, but where?

3
  • 1
    Is the server attached to the LED blocking the connection? If you're connected to the same LAN as that server, head to yougetsignal.com and check the Port Forwarding Tester. Commented Jan 4, 2013 at 7:09
  • Thanks, but the server is hosted and the remote device is in a different state. using the formed $url with 54512 port number, I can control the LED state from my iphone using Safari. No blocking. Commented Jan 4, 2013 at 7:20
  • If the error is in your code, it is most likely inside accessURL(). My first bet is that you should add http:// at the start - curl can do more then just HTTP and if you're using a custom port number, it can hardly gues the protocol. Commented Jan 4, 2013 at 7:42

2 Answers 2

4

Workarounds:

  1. Try $sensorIP = "http://77.134.85.187:54512";

  2. Make sure the outbound port 54512 is open (check with your hosting provider)

  3. After curl_exec() function, add $output = curl_getinfo($ch); and print and check the output. you can get some info from that.

  4. Dont include port number as part of url. Use the following instead:

    curl_setopt($ch, CURLOPT_PORT, '54512');

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks to George, Joey and Zack, I have already done all that you have suggested before my post. One exception is not adding http://. I assumed that since IP:80 works IP:54512 should work. I will give this a try.
I tried adding http:// and again curl_setopt($ch, CURLOPT_PORT, '54512'), no luck. True, I am not showing the accessURL ($url) function but it's very short and does a Curl_init() and Curl_Setop() calls. It is not to blame since IP:80 works.I called my hosting provider and they "guarantee" that port 54512 is not blocked on OUTGOING HTTP sends and the receiving device definitely has an open port since I can contact it with my iPhone using $url. Odd for sure. Al
I discovered that I can use any outgoing port < 100. So there is some oddity on the hosted platform I am using. It should support any outgoing port < 64K. My provider is in denial but my tests prove otherwise. So Curl/PHP users beware of this odd issue on at lease one or more hosted server platforms. Al
-1

I came across the same problem lately. I've tried almost everything, but no luck yet As far as I understood, curl does not work with other ports except 80. So the best solution here is to address curl on port 80 and you won't have any problems as I do now. Hope this info will help you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.