How do I force the php function ssh2_sftp() to crash or timeout instead of hanging?

42 Views Asked by At

I am trying to connect to ftp with the following code in php

$connection = ssh2_connect($host, $port);
ssh2_auth_password($connection, $user, $password);
$sftp = ssh2_sftp($connection);

However, instead of triggering an error, the script just hangs. When I try connecting via the linux command line, I get the error

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: <login date> from <my ip>
Could not chdir to home directory /xxx/xxx/./xxx/xxxx/xxx: No such file or directory
Connection to <my ip> closed.

How do I get the script to trigger an error (preferably something more specific about what happened) instead of hanging?

0

There are 0 best solutions below