super.t
super.t

Reputation: 2736

league/sftp Connection closed prematurely

I've got a long-living process controlled by supervisor written in php, it's a Laravel command listening on a redis channel. It pushes data from the channel to another server via SFTP using the leagure/sftp library when the data arrives. The problem that it works normally only during about 12 hours after starting the process and starts returning the following error thereafter:

File: /var/www/html/hub/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php

Line: 3416

Code: 0

Message: Connection closed prematurely

The process needs restarting to work normally another 12 hours.

Do you guys have any idea?

Upvotes: 1

Views: 4491

Answers (2)

super.t
super.t

Reputation: 2736

The problem is resolved by reconnecting every time before accessing the SFTP server:

/**
             * @var \Illuminate\Filesystem\FilesystemAdapter $disk
             */

            $adapter = $disk->getDriver()->getAdapter();
            $adapter->disconnect();
            $adapter->connect();

Upvotes: 2

It's same subject here or not?

[Perl][net::ssh2] How to keep the ssh connection while executing remote command

An other solution is re-auth to the server before the 12 hours.

Upvotes: 0

Related Questions