flysystem-sftp
flysystem-sftp copied to clipboard
ftp_rawlist(): php_connect_nonb() failed: Operation now in progress (115)
So within laravel I am trying to use this package in order to connect to remote host and send or even list files.
So in my config I have:
'ftp' => [
'driver' => 'ftp',
'host' => 'host',
'username' => 'username',
'password' => 'password',
'ssl' => false,
'passive' => 'false',
'ignorePassiveAddress' => true,
'port' => 21
],
Now I have also tried native solution like:
$host = config('filesystems.disks.ftp.host');
$user = config('filesystems.disks.ftp.username');
$password = config('filesystems.disks.ftp.password');
$ftpConn = ftp_connect($host);
$login = ftp_login($ftpConn, $user, $password);
//
//Enable PASV ( Note: must be done after ftp_login() )
//
$mode = ftp_pasv($ftpConn, TRUE);
// check connection
if ( (!$ftpConn) || (!$login) || (!$mode) ) {
echo 'FTP connection has failed! Attempted to connect to ' . $host . ' for user ' . $user . '.';
} else {
echo 'FTP connection was a success.';
$directory = ftp_nlist($ftpConn, '.');
dd('line');
echo '<pre>' . print_r($directory, true) . '</pre>';
}
ftp_close($ftpConn);
However in both cases I get same error, ftp_rawlist(): php_connect_nonb() failed: Operation now in progress (115)
pointing at line lluminate\Foundation\Bootstrap\HandleExceptions::handleError vendor/league/flysystem/src/Adapter/Ftp.php:570
I have tried it via Filezilla and it works fine, the php code runs inside ubuntu docker image. Is there anything I am missing here?
maybe add in vendor/league/flysystem/src/Adapter/Ftp.php
if (defined('FTP_USEPASVADDRESS')){
ftp_set_option($this->connection, FTP_USEPASVADDRESS, false);
}
before
if ( ! ftp_pasv($this->connection, $this->passive)) {
throw new ConnectionRuntimeException(
'Could not set passive mode for connection: ' . $this->getHost() . '::' . $this->getPort()
);
}
is this solution working ?
The issue above is related to FTP connections, not SFTP connections, this issue should be closed or moved to https://github.com/thephpleague/flysystem-ftp, most likely the issue is misconfiguration of the parameters, "passive" should be true.