Java模拟FTP客户端登录阿里云轻量服务器
报错:java.net.ConnectException: Connection timed out
- 分析原因是由于ftpClient.enterLocalPassiveMode()导致的;
该code的意思是,连接以FTP被动模式进行 - 解决方案:
阿里云FTP开启被动模式
vim /etc/vsftpd/vsftpd.conf //添加下面3句,然后在安全组打开3000-3005端口
pasv_enable=YES
pasv_min_port=3000
pasv_max_port=3005
转载自:https://blog.csdn.net/quliangmao/article/details/78885675
补充,FTP被动与主动模式(在实际生产过程中FTP基本是被动模式,因为客户端用户一旦有防火墙,就会导致FTP服务器主动与客户端开发端口建立连接失败)