LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-22-2016, 03:02 AM   #1
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
Java JSch library never closes SSH connections?


Hi guys

I'm trying to use JSch from the official Oracle Java SE 1.8 JVM for high numbers (tens of thousands) of file transfers between servers on the internet over SFTP.

Both machines on both sides run a fully updated Centos 7 instance. Both consistently run out of file handles due to JSch never closing any connections it uses, even with very explicit exiting and disconnecting of JSch exec and sftp channels, or even killing the Java app that was using JSch to create these connections. I have posted the code, and it apparently passes muster.

The strange thing is I've noticed if I close the Java application from which I opened the SSH connections, on the target Centos 7 server the SSH connections it opened via JSCh is still there if I run "netstat -tnpa | grep ssh".

If I completely shut down the PC that ran JSCh to open the connections on the target Centos 7 server, the connections are still there, reported by "netstat -tnpa | grep ssh".

If I make a putty or WinSCP connection from that PC to the Centos 7 server and I close putty or WinSCP, their SSH and SFTP connections are correctly dropped and there is one less SSH connection reported by "netstat -tnpa | grep ssh".

The ONLY way to ever flush dead "JSch-created" SSH sessions from the Centos 7 system is to physically reboot the Centos 7 machine.

This makes it impossible to use JSch to transfer the files - it will only transfer a set amount and the target Centos 7 machine then runs out of file handles and all file transfer stops as JSch never, ever flushes or actually closes an SSH session on the Centos 7 machine connected to... even closing the Java application that used JSch to open those sessions has no effect, the sessions stay open.

I've also left it for several days, SSH sessions created via JSch from the 1.8 Java SE JVM on Monday, are still there, in their thousands, on Friday - each single one.

Anybody got ANY idea why (and how) JSch can create "indestructible" SSH sessions on Centos 7's OpenSSH server?

How can I get JSch to -really- close an SSH connection?

Thanks!

Last edited by rylan76; 08-22-2016 at 03:03 AM.
 
Old 01-31-2017, 02:22 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Original Poster
Rep: Reputation: 103Reputation: 103
Just a note on this thread, the issue was resolved by upgrading to a more recent JSCH library version.
 
2 members found this post helpful.
Old 01-31-2017, 03:01 AM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Glad you have it resolved, and thanks for taking the time to return with the solution and mark the thread as solved!

That helps everyone.
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pure-FTPd closes connections shorto Linux - Server 8 10-15-2009 09:30 AM
SSH closes the connection right after the authentication Rauldinho Linux - Networking 2 09-05-2008 08:34 AM
jailkit closes ssh session xilace Linux - Software 7 10-07-2006 11:20 AM
Mozilla closes itself (java related?) Alex19ldr Linux - Newbie 2 05-15-2005 06:31 PM
java plugin closes my mozilla Zaius Linux - Newbie 4 01-11-2004 02:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration