java ftp连接被拒绝,FTP被动模式连接被拒绝

I'm creating an ftp client and I have a problem.

First, I create a socket where I sent USER and PASS then PASV a receive IP and PORT and then create a second data socket and try to connect, but there is a problem.

It will connect 5 times of 6, but on the 6th time I got error 111 Connection Refused and I have no idea how to fix this.

解决方案

The response text to PASV does not have a standardized format (EPSV does, though), so make sure you are parsing the IP/Port correctly, as you may receive one of many different formats used by real-world servers:

227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).

227 Entering Passive Mode (h1,h2,h3,h4,p1,p2

227 Entering Passive Mode. h1,h2,h3,h4,p1,p2

227 =h1,h2,h3,h4,p1,p2

Just to show a few possibilities.

If you are parsing the IP/Port correctly and still not able to connect, then either the server has too many client connections on the IP/Port and ran out of available slots for you to connect to, or else the IP/Port is being blocked by a firewall/router that the server does not know about when it reported the IP/Port to you.

Unfortunately, a connection refused error does not offer any way to differentiate between those conditions, so all you can do is attempt to connect a few times before failing the transfer, or else send an ABOR to inform the server to close the current passive IP/Port and then send a new PASV to get a new IP/Port.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值