From 966941ca7b4591c2b4ecc99b812967e1eaab58b8 Mon Sep 17 00:00:00 2001 From: Looly Date: Thu, 28 Mar 2024 23:28:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djsch=20session.openSftp()?= =?UTF-8?q?=E6=9C=AA=E6=89=93=E5=BC=80session=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/hutool/extra/ssh/engine/jsch/JschSftp.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hutool-extra/src/main/java/org/dromara/hutool/extra/ssh/engine/jsch/JschSftp.java b/hutool-extra/src/main/java/org/dromara/hutool/extra/ssh/engine/jsch/JschSftp.java index bb0ada80f..1e8a0199e 100644 --- a/hutool-extra/src/main/java/org/dromara/hutool/extra/ssh/engine/jsch/JschSftp.java +++ b/hutool-extra/src/main/java/org/dromara/hutool/extra/ssh/engine/jsch/JschSftp.java @@ -152,6 +152,15 @@ public class JschSftp extends AbstractFtp { .getRaw(); } + if (false == session.isConnected()) { + // issue#I9CH6A 首先Session需连接 + try { + session.connect((int) this.ftpConfig.getConnector().getTimeout()); + } catch (final JSchException e) { + throw new SshException(e); + } + } + // 创建Channel try { this.channel = (ChannelSftp) this.session.openChannel(ChannelType.SFTP.getValue());