使用隐式 ftps端口 990以及显式 ftps端口 21上传文件,但文件上传时为 0 字节

问题描述

以下代码以被动模式连接到远程机器

.container {
    white-space: pre-line;
}

我收到代码 226 成功传输文件时间戳也得到更新,但文件仍然为 0kb 空。

写操作失败,出现异常javax.net.ssl.SSLHandshakeException: No new session is allowed and no existing session can be resumed

从库代码中,它在 apache-commons-net 的 FTPSClient 的 public void connect(ConnectionManager connectionManager) throws IOException { Objects.requireNonNull(connectionManager,"Can't process with null ConnectionManager object."); if (connectionManager.getPort() == 990) { ftpsClient = new FTPSClient(true); //ftpsClient.setAuthValue("TLSv1.2"); //ftpsClient.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager()); } else { ftpsClient = new FTPSClient(); } ftpsClient.setConnectTimeout(connectionManager.getConnectionTimeout()); ftpsClient.connect(connectionManager.getHost(),connectionManager.getPort()); ftpsClient.login(connectionManager.getUsername(),connectionManager.getpassword()); if(ftpsClient.isConnected()) { ftpsClient.execPBSZ(0); ftpsClient.execPROT("P"); ftpsClient.setEnabledSessionCreation(false); //If I set this to true then it throws exception:450 TLS session of data connection has not resumed or the session does not match the control connection // ftpsClient.setNeedClientAuth(true); // ftpsClient.setWantClientAuth(true); // ftpsClient.setPassiveNatWorkaround(true); ftpsClient.enterLocalPassiveMode(); } ftpsClient.setSoTimeout(connectionManager.getSocketTimeout()); ftpsClient.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE); ftpsClient.setFileTransferMode(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE); ftpsClient.addProtocolCommandListener(new ProtocolCommandListener() { @Override public void protocolReplyReceived(ProtocolCommandEvent arg0) { log.info(arg0.getMessage()); } @Override public void protocolCommandSent(ProtocolCommandEvent arg0) { log.info(arg0.getMessage()); } }); } 处失败

上传文件,我使用以下代码

sslSocket.startHandshake()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...