java - FTPSClient 无法连接

标签 java spring tomcat

我一直在尝试将工作的 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/

相关文章:

java - (Libgdx) 使舞台和 spritebatch 中的一切变暗

c# - 可以与 WCF 交互的 Java Web 服务工具包

java - 用Java编写一个像Tomcat这样的服务器

java - 使用 spring java 使用带有 xml 响应数组列表的 Rest api

spring - MonitorFilter::WARNING:监控过滤器必须是链中的第一个过滤器

Java HashMap,一键多值,一张图

mysql - 404 未找到 :The origin server did not find a current representation for the target resource or is not willing to disclose that one exists

java - 服务层远程握手异常

java - 未调用 Spring MVC Controller - 但编译过程似乎很好

java - tomcat是否检测解压war的变化?