FTP被动模式连接被拒绝(FTP passive mode connection refused)

Posted 格格巫 MMQ!!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FTP被动模式连接被拒绝(FTP passive mode connection refused)相关的知识,希望对你有一定的参考价值。

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.

机译
我正在创建一个 ftp客户端,并且遇到问题。

首先,我创建一个套接字,在此处我发送USER和PASS,然后PASV接收IP和PORT,然后创建第二个数据套接字并尝试连接,但是存在问题。

它会连接6次的5次,但在第6次出现错误 111 Connection Refused 时,我有不知道如何解决这个问题。

解决方案
对 PASV 没有标准格式( EPSV ),因此请确保正确解析IP /端口,因为您可能会收到真实服务器使用的许多不同格式之一:

< pre> 227进入被动模式(h1,h2,h3,h4,p1,p2)。
227进入被动模式(h1,h2,h3,h4,p1,p2
227进入被动模式h1,h2,h3,h4,p1,p2
227 = h1,h2, h3,h4,p1,p2

只是为了展示一些可能性。 b
如果您正确解析IP /端口并且仍然无法连接,则服务器在IP /端口上的客户端连接太多,并且没有足够的可用插槽供您连接,否则IP /端口被防火墙/路由器阻塞,服务器不知道它何时向您报告IP /端口。

不幸的是, code>连接被拒绝错误没有提供任何区分这些条件的方法,所以你只能在失败之前尝试连接几次,否则发送一个 ABOR 通知服务器关闭当前的被动IP /端口,然后发送一个新的 PASV 来获得新的IP /端口。

以上是关于FTP被动模式连接被拒绝(FTP passive mode connection refused)的主要内容,如果未能解决你的问题,请参考以下文章

FTP Port主动模式 Passive被动模式区别-Filezilla Server设置Passive被动模式

ftp的passive模式

FTP的主动传输模式(PORT Mode)及被动传输模式(Passive Mode)(PASV)(FTP客户端 client 服务端 server 通信原理)

ftp的主动模式active mode和被动模式 passive mode的配置和区别

python ftp模块有支持passive off这个命令吗

大白话解释一下“被动FTP模式”是啥意思?