Question

I am using the phpseclib library for files downloaded from SFTP server. Sometimes the script does not download the file even there is a file in SFTP. Sometimes the file will download when we refresh a couple of times.

How can I reconnect automatically when the connection is lost?

Or

How to increase the active session time.

Was it helpful?

Solution

I guess you could put the code in a while loop. eg. while (action_not_done) { $sftp = new Net_SFTP(); ... }

If it's timing out... could be that your timeout is set pretty low for what you're trying to do. A PHP timeout of 10 seconds for downloading a 10GB file might not be enough.

If it's not something like that then posting logs would help. Here's an example of how to get them:

http://phpseclib.sourceforge.net/sftp/examples.html#logging

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top