diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index cd685438..8823a879 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3295,7 +3295,11 @@ class SSH2 if (!is_resource($this->fsock) || feof($this->fsock)) { $this->bitmap = 0; - throw new ConnectionClosedException('Connection closed (by server) prematurely ' . $elapsed . 's'); + $str = 'Connection closed (by server) prematurely'; + if (isset($elapsed)) { + $str.= ' ' . $elapsed . 's'; + } + throw new ConnectionClosedException($str); } $start = microtime(true);