FTP被动模式连接被拒绝 [英] FTP passive mode connection refused
问题描述
我正在创建一个 ftp客户端,并且遇到问题。
首先,我创建一个套接字,在此处我发送USER和PASS,然后PASV接收IP和PORT,然后创建第二个数据套接字并尝试连接,但是存在问题。
它会连接6次的5次,但在第6次出现错误 111 Connection Refused
时,我有不知道如何解决这个问题。
对 PASV
没有标准格式( EPSV
),因此请确保正确解析IP /端口,因为您可能会收到真实服务器使用的许多不同格式之一:
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 /端口。
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被动模式连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!