简体   繁体   中英

SFTP Mule Client Java API - User Login Time out Issue

I am working on a Java code to SFTP file to remote from HDFS filesystem. It works fine for smallers file less than 200 MB. For large files I get the following error.

     17/08/08 02:44:49 ERROR sftp.SftpClient: Error writing data over SFTP   service, error was: Failure
4: Failure
    at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2289)
    at com.jcraft.jsch.ChannelSftp.checkStatus(ChannelSftp.java:1937)
    at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:541)
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:439)
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:406)

My code is as follows:

            public static void sendFile(String targetDirectory, String   sourceFileWithFullPath) throws IOException {
    SftpClient client = new SftpClient("karthick");
    BufferedInputStream bis = null;
    Configuration conf = new Configuration();
    FileSystem fs = FileSystem.get(conf);
    FSDataInputStream fsdisPath = null;
    String filePath = null;
    try {

        filePath=sourceFileWithFullPath;
        Path inputPath = new Path(filePath);
        fsdisPath = fs.open(inputPath);
        bis = new BufferedInputStream(fsdisPath);
        client.login("karthick","/karthick/id_rsa", null);
        client.changeWorkingDirectory(targetDirectory);
        client.storeFile(inputPath.getName(), bis);
        System.out.println("The actual path is" + client.getAbsolutePath(sourceFileWithFullPath));

    }
    finally {
        if (client != null) {
            client.disconnect();
        }
        if (bis != null) {
            bis.close();
        }
    }
}

I ensured that I have enough disk space, no memory issues and all the required permissions. What could be other possible ways to avoid this issue. I am planning to have this utility to copy 500GB files. I am beginning java and learning the fundamentals now. Any suggestions would be greatly appreciated.

Update: I am receiving this error as well com.jcraft.jsch.JSchException: verify: false . I have added keys wherever necessary. How do I resolve this issue

    ERROR sftp.SftpClient: Error during login to karthick@karthick
    com.jcraft.jsch.JSchException: verify: false
    at com.jcraft.jsch.Session.connect(Session.java:295)
    at com.jcraft.jsch.Session.connect(Session.java:150)
    at org.mule.transport.sftp.SftpClient.login(SftpClient.java:178)

It looks like one of 4 reasons:
1)Permissions on the folder you're writing to
2)Spaces on the file path (or name).
3)Wrong slash in the file path.
4)Time out issues are happen while reading or writing the huge File..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM