php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39683 SSH does not disconnect gracefully
Submitted: 2006-11-29 14:42 UTC Modified: 2006-11-29 14:51 UTC
From: peter dot wilton-jones at eads dot com Assigned:
Status: Not a bug Package: *Network Functions
PHP Version: 5.2.0 OS: Windows 2003
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: peter dot wilton-jones at eads dot com
New email:
PHP Version: OS:

 

 [2006-11-29 14:42 UTC] peter dot wilton-jones at eads dot com
Description:
------------
I have a page that refreshes every minute. In that page, I open an ssh session and obtain data. There is no way to close the ssh connection. On reload, php opens a new connection but does not terminate the last one or reuse the existing one.
Running a NETSTAT command reveals numerous connections in the CLOSE_WAIT status after several minutes.
Can a close SSH option be included?

Reproduce code:
---------------
<?php
$connection = ssh2_connect('myserver',22);
ssh2_auth_password($connection,'username','password');
$stream = ss2_exec($connection,'df -k',FALSE);
stream_set_blocking($stream, TRUE);
$output = fread($stream,4096);
fclose($stream);
echo $output;
?>

Expected result:
----------------
Connection should show nothing

Actual result:
--------------
netstat -a shows

----------------
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
TCP     myweb:xxxx      myserver:22         CLOSE_WAIT
---------------

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-29 14:51 UTC] tony2001@php.net
Please report issues in PECL modules using PECL bug tracker.
http://pecl.php.net/bugs/search.php?cmd=display&status=Open&package_name[]=ssh2
Thank you.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 17:01:28 2025 UTC