Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Help needed: connection timeout
Hello txp people,
In this thread we are trying to import some file from a slow ftp server with file_get_contents
. It works fine on my server, taking about 5s to load, but fails on some other server, seemingly dropping the connection after exactly 3s. I guess some timeout is reached, but have no access to the second server, and very limited knowledge of server configuration. So any guidance would be very much appreciated in fixing the settings (php? apache? other?) causing the error.
Thank you.
Offline
Re: Help needed: connection timeout
This sets the socket timeout to 60 seconds and prints the old value for that setting. If it prints “3”, then that’s what was causing this problem. Put it just above the file_get_contents line.
echo ini_set('default_socket_timeout', 60);
Offline
Re: Help needed: connection timeout
Thank you, Ruud, I have tried it by reducing default_socket_timeout
to 2, but was still able to import the file (within ~7s). Could there be some other timeout interfering here?
nardo, could you test it?
Last edited by etc (2012-10-28 21:32:57)
Offline
#4 2012-10-29 06:48:15
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Help needed: connection timeout
I added this to the page template:
<txp:php>
echo ini_set('default_socket_timeout', 60);
var_dump(file_get_contents('ftp://ftp2.bom.gov.au/anon/gen/fwo/IDT16090.xml'));
</txp:php>
The output was:
60string(0) ""
I loaded the page again, same result.
Offline
#5 2012-10-29 09:05:35
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Help needed: connection timeout
does this link help in any way? Curl and ‘passive server’?
Offline
Re: Help needed: connection timeout
nardo wrote:
does this link help in any way? Curl and ‘passive server’?
Maybe, if you receive failed to open stream: FTP server reports RETR ...
or other errors, can you check? Or even simply try the suggested solution? It seems that file_get_contents
does not detect any error, it simply gets an empty response (from whom? proxy? firewall?). Are you able to import from ftp at all, could you try with some fast server? I can not reproduce the issue, so you have to do all this hard work. :)
Since that is not really etc_query
-related, may I suggest that we continue here and ask forum administrators to move there the posts starting with the Ruud’s one? Thank you.
Offline
#7 2012-10-29 10:59:23
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: Help needed: connection timeout
etc – I am using your plugin with a number of data feeds (small and large). No problems at all with HTTP feeds – but FTP protocol connections fail, even with very small data feeds. I have only tested on one server, so I will test with another tomorrow. I will also look for FTP feeds from another source.
Thanks for your help.
Offline
#8 2012-10-29 12:38:33
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Help needed: connection timeout
etc wrote:
may I suggest that we continue here and ask forum administrators to move there the posts starting with the Ruud’s one? Thank you.
Done :)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Help needed: connection timeout
uli wrote:
Done :)
Gratefully acknowledged :) Now patiently fishing big guys advices.
Offline