Dec 14, 2020
0
Level 2
Error 110. Connection timed out SFTP
I have the following code that connects to a remote SFTP service. It seems the company likes to block IP's randomly for no reason. I need to deal with the the Connection time out, but can't seem to catch it.
use League\Flysystem\Sftp\SftpAdapter;
function xxxx()
{
$adapter = new SftpAdapter([
'host' => $this->url,
'port' => $this->port,
'username' => $this->username,
'password' => $this->password,
'root' => $this->root,
'timeout' => 10,
]);
try {
$adapter->connect();
// for redundancy
if ($adapter->isConnected())
{
$filesystem = new Filesystem($adapter);
return $filesystem;
}
else
{
return "ERROR, this shouldn't happen!";
}
} catch (Exception $e) {
echo $e->getMessage();
Log::debug('Connection issue');
}
}
I've tried catch (Exception $e), catch (League\Flysystem\ConnectionErrorException $e) and catch (League\Flysystem\Sftp\ConnectionErrorException $e)
Thanks.
Please or to participate in this conversation.