New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close channel before trying to open again Exception is raised upon folder creation #1961
Comments
I can get a similar error if I try to do certain operations more than once. eg. $sftp->openShell();
$sftp->openShell(); I mean, I should prob update it to work more like the DocBlock comments describe: * Creates an interactive shell
*
* Returns bool(true) if the shell was opened.
* Returns bool(false) if the shell was already open. Anyway, it almost feels like what's going is that the connection is getting interrupted and then phpseclib is trying to reconnect. I think 8ecd156 should do the trick for you. Thanks! |
Thanks @terrafrost. Will upgrade and report back if the error happens again! |
@terrafrost, the issue still persists :-/. Any other ideas? |
So I was able to test my theory and had to make one more tweak for it to work: That said, if my theory were true you'd also need to do $ssh = new SFTP('localhost', 22);
$ssh->login('user', 'pass');
echo $ssh->pwd() . "\n";
sleep(2);
//$ssh->ping();
echo $ssh->pwd(); And let's also say your sshd_config file had this in it:
At that point the SSH server would disconnect between the two But is that what's actually going on in your case? idk. Outside of your stack trace I have very little information that I can work with. In order to say more definitely I'm going to need to have the SSH logs. You can get them by doing |
I just resolved a problem with a SFTP server using The problem was that I got a After some debugging I found out that aforementioned server disconnected after executing So I came up with this workaround: Storage::extend('sftp', function (Application $app, array $config) {
$config['connectivityChecker'] = new class extends SimpleConnectivityChecker {
public function isConnected(SFTP $connection): bool
{
if (parent::isConnected($connection)) {
$connection->ping();
return true;
}
return false;
}
};
return Storage::createSftpDriver($config);
}); Hopefully this will help anyone. |
@sandcore-dev I implemented your suggestion. EDIT: Forget what I just wrote... you have to use extend, otherwise the config is not cacheable. You could still modify your code to use Storage::extend('sftp', function (Application $app, array $config) {
$config['connectivityChecker'] = new SimpleConnectivityChecker(true);
return Storage::createSftpDriver($config);
}); However, this didn't solve my issue. Here is my stack trace of the exception starting with the
The additional Might be a dumb question, but can a SFTP connection handle two simultaneous write requests? It's already dawning on me that if I have two processes run in the queue trying to write simultaneously to the same sftp connection, this might cause the reported error. Can someone confirm this please? |
I am using the
flysystem-sftp-v3
in a Laravel app which uploads files to a SFTP server around 500times a month. Occasionally I get the errorPlease close the channel (256) before trying to open it again
fromSSH2::openChannel()
when trying to runStorage::disk(’sftp’)->makeDirectory(‘folder_name’)
.I tried to check the code to understand what the error means and how to avoid it, but I wasn’t able to figure it out myself. Can someone explain to me or point me in the right direction on when this happens and why?
The text was updated successfully, but these errors were encountered: