2tu commented on issue #294: URL: https://github.com/apache/mina-sshd/issues/294#issuecomment-1474875952
I switched to SftpClient and it's working normally now. in **_ThreadPool_** use #### Bad ```java public String downloadFile(String path) { try (ClientSession session = client.connect(username, host, port).verify(timeout, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(password); session.auth().verify(); try (SftpFileSystem fs = SftpClientFactory.instance().createSftpFileSystem(session); ByteArrayOutputStream out = new ByteArrayOutputStream() ) { Path targetPath = fs.getDefaultDir().resolve(path); Files.copy(targetPath, out); return out.toString("UTF-8"); } } catch (SftpException e) { log.error("download file:{} error:{}.", path, e.getMessage()); } catch (Exception e) { log.error("download file:{} error.", path, e); } return null; } ``` #### Good Version:2.8.0 ```java public String downloadFile(String path) { try (ClientSession session = client.connect(username, host, port).verify(timeout, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(password); session.auth().verify(); SftpClientFactory factory = SftpClientFactory.instance(); try (SftpClient sftp = factory.createSftpClient(session); StringWriter writer = new StringWriter();) { InputStream inputStream = sftp.read(path); IOUtils.copy(inputStream, writer, StandardCharsets.UTF_8); String contentStr = writer.toString(); return contentStr; } } catch (IOException e) { log.error("download file:{} error.", path, e); } return null; } ``` After downloading, moving, and parsing approximately 40142 files, Each file has an approximate size of 4KB. ![image](https://user-images.githubusercontent.com/14172964/226114375-8230f563-4c85-4f60-8e75-ebb295ee404e.png) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org