...

View Full Version : Getting Invalid Request Warning While Using Fsockopen



Sandeep2010
05-27-2011, 10:17 PM
Hello

I am behind a proxy server and I want to make a request using fsockopen. But I am always getting a warning Invalid Request: Requested URL could not be retrieved.

The code I am using is given below:



<?php
$fp = fsockopen("ps1.iiit-bh.ac.in", 8080, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.gadgeticworld.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>

The error page looks like this:

http://www.elaxtro.com/img1.bmp

Any Help will be highly appreciated. I need to fix this issue.

Thanks A Lot! :)

Fumigator
05-28-2011, 09:40 AM
Include the http:// in your URL.

Sandeep2010
05-28-2011, 10:26 AM
Include the http:// in your URL.

After including http:// also it is not working. The same error page is being displayed.

Fou-Lu
05-28-2011, 05:00 PM
Typically you don't want to specify the protocol within the name unless its using tls or udp. The protocol is inferred from the port that is in use, so just the dns name and socket are sufficient. Specifying http and a socket would try to map both, so it would logically look for http://http://dns.com, which definitely wouldn't work.

I also cannot attach to that domain on either port 80 or 8080, so that simply indicates that it is invalid, as was the result of your return.

Sandeep2010
05-28-2011, 06:46 PM
Typically you don't want to specify the protocol within the name unless its using tls or udp. The protocol is inferred from the port that is in use, so just the dns name and socket are sufficient. Specifying http and a socket would try to map both, so it would logically look for http://http://dns.com, which definitely wouldn't work.

I also cannot attach to that domain on either port 80 or 8080, so that simply indicates that it is invalid, as was the result of your return.

So, what is the solution to this problem?

Fou-Lu
05-28-2011, 08:03 PM
So, what is the solution to this problem?

Well, its not a PHP issue. The DNS you've provided doesn't resolve to a machine - at least not on that port (and it won't respond to icmp traffic either). So the solution is to find a host that can be resolved.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum