When I try to run my script from local server it works, but doesn't work from web server.
My Script:
$url="http://91.101.61.111:91/SendRequest/?mobile=9999999999&id=11011&reqref=501";
$request_timeout = 60;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $request_timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$curl_errorno = curl_errno($ch);
$curl_error = curl_error($ch);
$getserver= curl_getinfo($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = preg_split("/[\s]+/", $output);
$rstatus = $response[0]." ".$response[1];
if ($rstatus == "REQUEST ACCEPTED")
{
$raccepted = preg_match('/([\w\s]+) your ref=([\d]+) system_reference=([\w]+)/', $output, $matches);
$status = $matches[1];
$myref = $matches[2];
$sysref = $matches[3];
echo "Status is $status, My Ref ID is $myref, Mars Ref ID is $sysref";
}
elseif ($rstatus == "REQUEST ERROR")
{
$rerror = preg_match('/([\w\s]+) errorno=([\d]+);your ref=([\d]+);system_reason=([\w\s]+)/', $output, $matches);
$status = $matches[1];
$errorno = $matches[2];
$myref = $matches[3];
$sysref = $matches[4];
echo "Status is $status, Error No is $errorno, My Ref ID is $myref, Mars Message is $sysref";
}
echo "<br/><br/>";
echo "Output: ".$output;
echo "<br/><br/>";
echo "Curl HTTP Response Code: ".$httpcode;
echo "<br/><br/>";
echo "Curl Error Code: ".$curl_errorno;
echo "<br/><br/>";
echo "Curl Error: ".$curl_error;
Please note that 91.101.61.111 is my static ip And I have a modem installed on port 91. I need to send request to my modem using the above script.
When I try to run the script from my local pc server (localhost/script.php) it works well. But when I try to run it from my web server (mywebsite.com/script.php), I get this response of the script:
Output:
Curl HTTP Response Code: 0
Curl Error Code: 7
Curl Error: Failed to connect to 59.92.77.151 port 91: Connection refused
There's no any IP has been blocked on my both server. No any firewall. Still connection refused.
Please help!
OS on Web Server: Linux
OS on Remote Server: Windows
Web Server:Apache