You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Seshkrishna Golla <se...@altair.com> on 2019/02/05 12:47:26 UTC

Information required on Asynchronous file transfer using SCP on Apache SSHD

Hi Team,

I have a requirement with Apache SSHD,
               Requirement:   Need to send multiple files(consider 100 files are stored in different locations in local file system) to remote server using ScpClient. I can able to do this with the below code, considering the below snippet the file transfer is sequential. But I want to transfer all the files in parallel (Asynchronous way). Could you please help to get me out here? Is there any test cases already developed? Please share the info ASAP.

               public static void multipleFilesUpload() {
             try (SshClient client = setUpClient()) {
                    client.start();
                    SimpleClient simple = SshClient.wrapAsSimpleClient(client);
                    simple.setConnectTimeout(CONNECT_TIMEOUT);
               simple.setAuthenticationTimeout(AUTH_TIMEOUT);

               scpClient = new SimpleScpClientImpl(simple);
                    CloseableScpClient scp = login("192.168.33.23", 22, "user", "passwd");
                    String localFile1 = "C:\\Users\\seshkg\\Desktop\\Inputs_Final\\2GB.sh";
                    String localFile2 = "C:\\Users\\seshkg\\Desktop\\Inputs_Final\\500mb.exe";

                    String[] localFile = {localFile1, localFile2};
                    String remotePath = "/tmp/";
                    scp.upload(localFile, remotePath);

                    client.stop();
                    simple.close();

             } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
             }

       }


Regards
Seshkrishna

[Altair_horizontal_CMYK_wout_guides]
Altair | Innovation Intelligence(r)


RE: Information required on Asynchronous file transfer using SCP on Apache SSHD

Posted by Seshkrishna Golla <se...@altair.com>.
Hi Team,

Could you please assist me to resolve the below issue.

org.apache.sshd.common.channel.exception.SshChannelClosedException: write(ChannelOutputStream[ChannelExec[id=221, recipient=2]-ClientSessionImpl[david@/192.168.33.23:22]] SSH_MSG_CHANNEL_DATA) len=8192 - channel already closed
     at org.apache.sshd.common.channel.ChannelOutputStream.write(ChannelOutputStream.java:110)
     at org.apache.sshd.common.util.io.IoUtils.copy(IoUtils.java:128)
     at org.apache.sshd.common.scp.ScpHelper.sendStream(ScpHelper.java:552)
     at org.apache.sshd.common.scp.ScpHelper.sendFile(ScpHelper.java:483)
     at org.apache.sshd.common.scp.ScpHelper.send(ScpHelper.java:442)
     at org.apache.sshd.common.scp.ScpHelper.send(ScpHelper.java:420)
     at org.apache.sshd.client.scp.AbstractScpClient.lambda$upload$0(AbstractScpClient.java:151)
     at org.apache.sshd.client.scp.DefaultScpClient.runUpload(DefaultScpClient.java:142)
     at org.apache.sshd.client.scp.AbstractScpClient.upload(AbstractScpClient.java:150)
     at org.apache.sshd.client.scp.ScpClient.upload(ScpClient.java:108)
     at org.apache.sshd.client.scp.ScpClient.upload(ScpClient.java:104)
     at org.apache.sshd.UploadFile.call(UploadFile.java:18)
     at java.util.concurrent.FutureTask.run(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

?       at java.lang.Thread.run(Unknown Source)


Regards
Seshkrishna

[Altair_horizontal_CMYK_wout_guides]
Altair | Innovation Intelligence(r)

From: Seshkrishna Golla
Sent: 05 February 2019 18:17
To: dev@mina.apache.org
Cc: seshukrishna.rgukt@gmail.com
Subject: Information required on Asynchronous file transfer using SCP on Apache SSHD

Hi Team,

I have a requirement with Apache SSHD,
               Requirement:   Need to send multiple files(consider 100 files are stored in different locations in local file system) to remote server using ScpClient. I can able to do this with the below code, considering the below snippet the file transfer is sequential. But I want to transfer all the files in parallel (Asynchronous way). Could you please help to get me out here? Is there any test cases already developed? Please share the info ASAP.

               public static void multipleFilesUpload() {
             try (SshClient client = setUpClient()) {
                    client.start();
                    SimpleClient simple = SshClient.wrapAsSimpleClient(client);
                    simple.setConnectTimeout(CONNECT_TIMEOUT);
               simple.setAuthenticationTimeout(AUTH_TIMEOUT);

               scpClient = new SimpleScpClientImpl(simple);
                    CloseableScpClient scp = login("192.168.33.23", 22, "user", "passwd");
                    String localFile1 = "C:\\Users\\seshkg\\Desktop\\Inputs_Final\\2GB.sh";
                    String localFile2 = "C:\\Users\\seshkg\\Desktop\\Inputs_Final\\500mb.exe";

                    String[] localFile = {localFile1, localFile2};
                    String remotePath = "/tmp/";
                    scp.upload(localFile, remotePath);

                    client.stop();
                    simple.close();

             } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
             }

       }


Regards
Seshkrishna

[Altair_horizontal_CMYK_wout_guides]
Altair | Innovation Intelligence(r)