PDA

View Full Version : [ubuntu] fopen error, yet I can wget fine...



tommyrot
November 27th, 2008, 10:00 PM
Hey folks,

I'm pretty new to the Ubuntu server side of things, and have gradually been getting my out-of-the-box 8.04.1 LAMP setup working how I want. However, there's one little thing that I can't seem to fix.

Whenever I attempt to execute the following fopen script...



<?php

$filename = "http://www.yahoo.com.au";
$handle = fopen($filename, "r");
$html = fread($handle, filesize($filename));
fclose($handle);

echo $html;

?>

... I get the following errors:



Warning: fopen(http://www.yahoo.com.au) [function.fopen]: failed to open stream: Connection timed out in /var/www/brushtail_3.1/sql/fopen.php on line 5

I can wget the desired URL without any problems (which would suggest that the network side of things is configured ok?), and I've enabled the allow_url_fopen = On value in my php.ini file.

Any thoughts about what I need to check from here?

Thanks in anticipation,

Tom

MJN
November 28th, 2008, 12:36 AM
Hi Tom,

I know absolutely nothing about PHP but until someone that does comes along I can offer some suggestions from what I do know about.

Firstly, do you use a proxy? Or just straight connections? (I'm wondering if wget might be proxy-aware but PHP isn't)

Secondly, have you tried running a packet sniffer (e.g. Wireshark) to see if the HTTP GET request gets sent out? If so, where to? And what, if anything, comes back?

Certainly the 'Connection timed out' error implies a request is being sent but no reply is being received which begs the immediate question of where this request is being sent...

Mathew