Goldeneye Posted November 30, 2009 Share Posted November 30, 2009 Hello! Here is the situation: The server I host my website on just upgraded it's PHP build from 4.4.* to 5.2.4. Not just PHP was upgraded, MySQL, postGres, and (I think) Apache were upgraded as well. Before the upgrade, my site worked perfectly. But now, whenever I access my site, it takes a long time to complete a request and all that is returned is "Warning: fopen(<THE_URL>) [function.fopen]: failed to open stream: Connection timed out in..." I know where the error is -- it's in my templating class. I check the remote server's configuration and the directive "allow_url_fopen is enabled and safe_mode is disabled. The strange thing is that my script works on my local server perfectly which is using PHP build 5.2.5. I looked for any differences between my local-server's PHPINFO() and my remote-server's PHPINFO() and, while I didn't find anything eye-catching yet, I noticed that virtual-directory-support is disabled on my remote-server and it is enabled on my local-server. Would that be what's causing the problem? If not, what are some potential causes for fopen() to behave this way? Link to comment https://forums.phpfreaks.com/topic/183393-what-are-causes-of-a-connection-timeout-with-fopen/ Share on other sites More sharing options...
trq Posted November 30, 2009 Share Posted November 30, 2009 Are you trying to open a remote file or using http to access a local file? Link to comment https://forums.phpfreaks.com/topic/183393-what-are-causes-of-a-connection-timeout-with-fopen/#findComment-967999 Share on other sites More sharing options...
Goldeneye Posted November 30, 2009 Author Share Posted November 30, 2009 I'm trying to access a local-file. I use an absolute-path, though such as "http://foo.bar/tpl/site_header.html" Link to comment https://forums.phpfreaks.com/topic/183393-what-are-causes-of-a-connection-timeout-with-fopen/#findComment-968007 Share on other sites More sharing options...
trq Posted November 30, 2009 Share Posted November 30, 2009 That is a url not an absolute path. Try an absolute path instead. eg; $_SERVER['DOCUMENT_ROOT'] . '/tpl/site_header.html' Link to comment https://forums.phpfreaks.com/topic/183393-what-are-causes-of-a-connection-timeout-with-fopen/#findComment-968008 Share on other sites More sharing options...
Goldeneye Posted November 30, 2009 Author Share Posted November 30, 2009 That does work, I might have to switch over to using that as much as I dread making all the changes through my scripts to use an absolute to point at my template files. I'm still curious about why using a URL in fopen() now results in a connection-timeout, though. Link to comment https://forums.phpfreaks.com/topic/183393-what-are-causes-of-a-connection-timeout-with-fopen/#findComment-968013 Share on other sites More sharing options...
trq Posted November 30, 2009 Share Posted November 30, 2009 Using a url means your reading the files via a request to your server. Its allot slower than accessing it via the filesystem directly however it should still work considering allow_url_fopen is enabled. Link to comment https://forums.phpfreaks.com/topic/183393-what-are-causes-of-a-connection-timeout-with-fopen/#findComment-968015 Share on other sites More sharing options...
Goldeneye Posted November 30, 2009 Author Share Posted November 30, 2009 It should -- in fact, it works perfectly on my local server running PHP 5.2.5. It worked on my remote server *before* it got upgraded from PHP 4.4.* to PHP 5.2.4. Well I queried the PHP error in a search engine and found a few relevent results. The only other explanation I can think of (that I found from querying a search engine) is that the server got reconfigured not to allow requests to access its files via a (seemingly) remote-HTTP-request. Or perhaps even that the request is being blocked by a firewall on the remote server. Link to comment https://forums.phpfreaks.com/topic/183393-what-are-causes-of-a-connection-timeout-with-fopen/#findComment-968017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.