Hi,
Here is my source code to put file to SFTP server:
Jsch jsch = new JSch();
Session session = jsch.getSession(username, hostName, port);
// set configuration params goes here
..........
session.connect();
ChannelSftp sftpChannel = (ChannelSftp)session.openChannel("sftp");
sftpChannel.connect();
sftpChannel.put(localFile, remoteFile);
// below is my method to check directory existence
try {
SftpATTRS attrs = sftpChannel.stat(remotePath);
return attrs!=null && attrs.isDir();
} catch (Exception e) {
if(JschUtil.getErrorType(e) == JschUtil.ERROR_FILE_NOT_FOUND) {
return false;
}
throw e;
}
// session will be kept to transfer file in the future
With small number of files and without directory existence checking, it works
fine.
There's a note that the above piece of code is executed simultaneously in
different applications/threads. So, there are multiple sessions and channels
point to a same directory. Do you think it will cause the issue?
Thanks,
Linh Nguyen
________________________________
From: Atsuhiko Yamanaka <y...@jcraft.com>
To: vlsuperman2...@yahoo.com
Cc: jsch-users@lists.sourceforge.net
Sent: Tuesday, February 7, 2012 3:37 PM
Subject: Re: [JSch-users] Fw: SFTP directory existence checking error
Hi,
+-From: Nguyen Tran Vu Linh <vlsuperman2...@yahoo.com> --
|_Date: Tue, 7 Feb 2012 00:22:10 -0800 (PST) ____________
|
|I'm using Jsch version 0.1.45 and I encountered an error as
|described below:
|- When I keep SFTP channel connecting with SFTP server and
| transfer multiple files (~1000), it throws out the exception
| "Pipe closed" at the directory existence checking function.
|- When I transfer files one-by-one (e.g. connect, put file,
| disconnect, and then connect again....), it works fine.
|
...
|In version 0.1.46, I could see that this is not fixed.
|Do you consider it as a critical bug?
I have not understood the relation between an exception from
ChannelSftp#stat() and many files transferred. Will it not happen
with the small number of transfered files? And, without the directory
existence checking, will it be succeeded?
It will be helpful if you show code to reproduce it.
Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
Skype callto://jcraft/
Twitter: http://twitter.com/ymnk
Facebook: http://facebook.com/aymnk
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users