Connection Timeout

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

Connection Timeout

Postby jjohn » Mon Aug 05, 2013 5:21 pm

I've already been able to successfully connect, but it often gives me the following:

Notice: Cannot connect to host. Banner timeout in /admin/Net/SSH2.php on line 852


or...

Notice: Cannot connect to host. Error 110. Connection timed out in admin/Net/SSH2.php on line 831


The code:

Code: Select all
$ssh = new Net_SSH2('host');

if (!$ssh->login('username', 'password')) {
    exit('The connection failed.');
}

echo $ssh->exec('ls /Users/John/files/');


However, it connects sometimes and that's fine, but now I am trying to download a file.

Code: Select all
$scp = new Net_SCP($ssh);

$content = $scp->get('/Users/John/files/thefile.jpg');

var_dump($content);


But this just keeps loading, and loading and loading and never seems to finish. Why is that? Anything I can do on my SSH server, configuration, etc etc?
Last edited by jjohn on Fri Aug 16, 2013 4:36 pm, edited 3 times in total.
jjohn
Traveler
 
Posts: 2
Joined: Mon Aug 05, 2013 5:14 pm

Re: Connection Timeout

Postby TerraFrost » Mon Aug 05, 2013 7:26 pm

Notice: Cannot connect to xxx.xxx.xxx.xxx. Error 110. Connection timed out in /path/to/Net/SSH2.php on line 831

That's an error produced by fsockopen so there's not going to be a ton I'm gonna be able to do.

Save for maybe suggest that you make use of phpseclib's third parameter. eg.

Code: Select all
$ssh = new Net_SSH2('...', 22, 60);

That'll have it connect with a timeout of 60 seconds instead of the default 10.

As for the SCP issue...

First, I'd recommend using Net_SFTP over Net_SCP if at all possible. Net_sFTP is, overall, a lot more versitle than Net_SCP.

Second... maybe you could get me the logs? eg.

Code: Select all
define('NET_SSH2_LOGGING', NET_SSH2_LOG_REALTIME);

$scp = new Net_SCP($ssh);

$content = $scp->get('/Users/John/files/thefile.jpg');

var_dump($content);
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Connection Timeout

Postby jjohn » Mon Aug 05, 2013 10:19 pm

Hello, thank your for your quick reply!

It connects more often now, thank you!

Yes, I moved to use NET_SFTP. I found out that I only have Read access to the Folder I was trying to access, I believe that could be the reason why it's not allowing me to upload/download any files, am I right?
jjohn
Traveler
 
Posts: 2
Joined: Mon Aug 05, 2013 5:14 pm

Re: Connection Timeout

Postby TerraFrost » Tue Aug 06, 2013 10:29 pm

Yes, I moved to use NET_SFTP. I found out that I only have Read access to the Folder I was trying to access, I believe that could be the reason why it's not allowing me to upload/download any files, am I right?

I'm not sure lol. I don't have as much experience with SCP as I do with SFTP but I can (as time permits) try to create a test environment to duplicate that setup and see if I get the same behavior.
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 1 guest

cron