【发布时间】:2019-04-25 19:59:41
【问题描述】:
我正在尝试通过 Wi-Fi 在我的本地网络上用 Java 设置 FTP 服务器。而且我坚持处理EPSV ALL 命令。作为客户,我在 iPhone 上使用 VLC 播放器。当我尝试播放 .mp4 文件时,它正在向服务器发送EPSV ALL。此行的服务器响应:
"229 Entering Extended Passive Mode (|||" + freeDataPort + "|)"
服务器在freeDataPort 上创建serverSocket,监听收入连接,没有任何反应。
我已经尝试通过连接到 FileZilla 服务器打开电影 - 它可以正常工作。我也无法理解为什么客户端在此命令(EPSV)之后尝试建立第二个连接(请求用户并再次传递的连接),而PASV 命令创建数据连接并进行简单的数据传输,例如响应LIST ,在第一个处理。
这是我使用的EPSV 的处理程序:
private void handleEpsv() {
sendMsgToClient("229 Entering Extended Passive Mode (|||" + freeDataPort + "|)");
try {
dataSocket = new ServerSocket(freeDataPort);
System.out.println("waiting for connect... port: " + freeDataPort);
dataConnection = dataSocket.accept();
dataOutWriter = new PrintWriter(dataConnection.getOutputStream(), true);
} catch (IOException e)
{
debugOutput("Could not create data connection.");
e.printStackTrace();
}
}
最后的结果:
FTP Server started listening on port 21
{/192.168.0.105=INITIALThread-0 Threads in data list: 0}
New connection received. Worker was created.
from INITIAL THREAD
Thread-0 - send to client: 220 Welcome to the FTP-Server
USER a from INITIAL THREAD
Thread-0 - send to client: 331 User name okay, need password
PASS a from INITIAL THREAD
Thread-0 - send to client: 230 User logged in successfully
SYST from INITIAL THREAD
Thread-0 - send to client: 215 UNIX Type: L8
PWD from INITIAL THREAD
Thread-0 - send to client: 257 "/"
TYPE I from INITIAL THREAD
Thread-0 - send to client: 200 OK
CWD // from INITIAL THREAD
Thread-0 - send to client: 250 CWD successful. / is current directory
PASV from INITIAL THREAD
Thread-0 - send to client: 227 Entering Passive Mode (192,168,0,199,7,232)
waiting for connect... port: 2024
Data connection - Passive Mode - established
LIST from INITIAL THREAD
Thread-0 - send to client: 125 Opening ASCII mode data connection for file list.
from INITIAL THREAD
Thread-0 - send to client: 226 Transfer complete.
{/192.168.0.105=INITIALThread-0 Threads in data list: 1}
New connection received. Worker was created.
Thread-1 - send to client: 220 Welcome to the FTP-Server
FEAT
Thread-1 - send to client: 211-Features:
Thread-1 - send to client: MDTM
Thread-1 - send to client: REST STREAM
Thread-1 - send to client: SIZE
Thread-1 - send to client: MLST type*;size*;modify*;
Thread-1 - send to client: MLSD
Thread-1 - send to client: UTF8
Thread-1 - send to client: CLNT
Thread-1 - send to client: MFMT
Thread-1 - send to client: EPSV
Thread-1 - send to client: EPRT
Thread-1 - send to client: 211 END
USER a
Thread-1 - send to client: 331 User name okay, need password
PASS a
Thread-1 - send to client: 230 User logged in successfully
EPSV ALL
Thread-1 - send to client: 229 Entering Extended Passive Mode (|||2025|)
used by Thread-1 Thread DATA type
waiting for connect... port: 2025
【问题讨论】: