|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi all,
I'm trying to get the contents of a file from a URL using file_get_contents() or file(). It doesn't work, it eventually just times out. It used to display a 'failed to open file' message but now returns nothing at all. - it works with any site that's not on our server, eg: google.com - allow_url_fopen is ON (proven with the above test) - we have two load balanced servers with identical settings, could this be an issue? Thanks, Mat Marlow |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 12 Sep, 11:17, mmar...@gmail.com wrote:
> Hi all, > I'm trying to get the contents of a file from a URL using > file_get_contents() or file(). It doesn't work, it eventually just > times out. It used to display a 'failed to open file' message but now > returns nothing at all. > > - it works with any site that's not on our server, eg: google.com > - allow_url_fopen is ON (proven with the above test) > - we have two load balanced servers with identical settings, could > this be an issue? > Its an issue if you want to fetch local files this way. Probably not a PHP isue though - more likely to be name resolution or firewall settings. Try using wget from the command line on the server to do the same thing and/or sniffing an attempt to connect. C. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
mmarlow@gmail.com wrote:
> Hi all, > I'm trying to get the contents of a file from a URL using > file_get_contents() or file(). It doesn't work, it eventually just > times out. It used to display a 'failed to open file' message but now > returns nothing at all. > > - it works with any site that's not on our server, eg: google.com > - allow_url_fopen is ON (proven with the above test) > - we have two load balanced servers with identical settings, could > this be an issue? > > Thanks, > Mat Marlow > Mat, First of all, if it used to display a message but doesn't now, something has changed. Check phpinfo() to ensure there wasn't an inadvertent change, i.e. due to an upgrade of PHP, someone else changing the php.ini file, etc. If phpinfo() looks good, go to a command line and try to access the page with telnet, i.e. telnet example.com 80 GET / (press enter again) See if you get the page back. If so, the problem is in your PHP code. If you don't, the problem is not in your php code, but your site or the remote. It could be, for instance, the site has changed to require an HTTP version, i.e. GET / HTTP/1.1 And I'm not sure file() or file_get_contents() will send such a header. I never traced it. But if that is the case, you may have to use CURL to get the page. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Thanks for your responses folks.
- I've tried CURL, with the same result. - I have also SUCCESSFULLY tested this using the same files from our local server, and it returns the contents of the page no problem With that in mind, I think the firewall idea might be something to look into. It does seem to be some problem with our server accessing itself so I guess we could start there unless anyone has any more bright ideas? thanks again, Mat |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Wed, 12 Sep 2007 10:17:10 -0000, mmarlow@gmail.com wrote:
>Hi all, >I'm trying to get the contents of a file from a URL using >file_get_contents() or file(). It doesn't work, it eventually just >times out. It used to display a 'failed to open file' message but now >returns nothing at all. > >- it works with any site that's not on our server, eg: google.com >- allow_url_fopen is ON (proven with the above test) >- we have two load balanced servers with identical settings, could >this be an issue? I had a similar problem when a hosting company started using a load balancer. I wanted to share a file from a subdomain amongst various other subdomains (it was actually a file containing some exchange rate data that I wanted to be common between various subdomains). The hosting company's support people gave me their solution: include 'http://www.sub.mydomain.dom.web-internal.hostdomain.net/myfile.php'; Maybe your hosting company can do something similar ... -- Regards, Paul Herber, Sandrila Ltd. http://www.sandrila.co.uk/ |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
mmarlow@gmail.com wrote:
> Thanks for your responses folks. > > - I've tried CURL, with the same result. > - I have also SUCCESSFULLY tested this using the same files from our > local server, and it returns the contents of the page no problem > > With that in mind, I think the firewall idea might be something to > look into. It does seem to be some problem with our server accessing > itself so I guess we could start there unless anyone has any more > bright ideas? > > thanks again, > Mat > If it's working on another server, then the code itself is OK. So it's got to be something on the server itself. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
![]() |
| Outils de la discussion | |
|
|