Open iamdto opened 11 years ago
@iamdto Thanks for info. I will try to think how we can fix that... not sure if we can check if reconnect is needed and do it automatically... if not we can do this workaround and make connect method public
In case we can't check if refresh is needed, I was thinking about an option (called something like limit
) which would states the number of calls to getConnection()
before the connection is forced.
Something like :
<?php
private function getConnection()
{
if (!$this->isConnected() || $options['limit'] <= $this->calls) {
$this->connect();
}
return $this->connection;
}
Of course it would be set to null
or false
by default.
What do you think about that ?
@iamdto Is this still relevant?
I didn't follow the activity on this project for a long time. I can see that @Zeichen32 PR is closed but not merged. Is there any workaround in the current code that fix this issue? If no, yes it's still relevant.
Hey. It seems I have the same problem.
Hi, I have exactly the same probleme than every one. After "googleing" I find this : http://grokbase.com/t/php/php-general/142j6a3gcd/testing-php-ftp-connection-if-still-connected
Who explain why "is_resource" is not a good idea.
Using the FTP adapter with
passive: true
, I recently ran into an issue where the connection looked OK but the call toftp_nlist
inGaufrette\Adapter\Ftp::exists()
failed, returningfalse
.Before it fails I successfully manage to proceed 60 files.
To be clear :
Gaufrette\Exception\FileNotFound
is thrown.Gaufrette\Adapter\Ftp::exists()
I can see that$this->getConnection()
returnsresource(490) of type (FTP Buffer)
(meanings the connection is good, right ?).$items
isfalse
(whereas it contained files for the 60 first calls).A temporary workaround is to change the access of
Gaufrette\Adapter\Ftp::connect()
so it ispublic
, and call it before processing each keys.But I am not sure it is a good solution.
Someone on the PHP manual also says that in such case we should refresh the connection.
What's your point of view on this one ? Should we add some kind of time out option ?