gpt4 book ai didi

java - FTPSClient 无法连接

转载 作者:行者123 更新时间:2023-11-28 22:18:49 24 4
gpt4 key购买 nike

我一直在尝试将工作的 FTP 连接 FTPClient 更改为 apache 提供的 FTPSClient。所做的唯一更改是更改类并指示应用程序将要连接的端口。服务器连接到同一网络中的另一台服务器。对于外部服务器,需要代理。

我已经尝试将构造函数设置为 true,它显示以下消息:

Unrecognized SSL message, plaintext connection?

final FTPSClient ftp = new FTPSClient( true );
//same results
//final FTPSClient ftp = new FTPSClient("SSL", true );
//final FTPSClient ftp = new FTPSClient("TLS", true );
ftp.setDefaultPort(22);

当我将其设置为 false 时,连接会挂断很长时间。它显示以下消息:

Could not parse response code. Server Reply: SSH-2.0-OpenSSH_4.1

tomcat 显示如下页面:

Proxy Error

The proxy server received an invalid response from an upstream server. The proxy server could not handle the request POST /myapppath/APage.htm.

Reason: Error reading from remote server

final FTPSClient ftp = new FTPSClient( false );
ftp.setDefaultPort(22);

我尝试通过 SFTP 手动连接 WinSCP,连接成功。

最佳答案

FTPS(基于 SSL/TLS 的 FTP)与 SFTP(SSH 文件传输)不同;这是两个完全不同的协议(protocol)。您收到错误 Unrecognized SSL message, plaintext connection? 的原因是您没有连接到 FTPS 服务器。

You can read more about the difference here.如果您想建立 SFTP 连接而不是 FTPS 连接,我建议使用 JSch library .

关于java - FTPSClient 无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31485873/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com