FTP 客户端可以控制 FTP 服务器超时设置吗?
Can the FTP client control FTP server time-out settings?
我在 Java
中使用 Apache Commons-Net 库
我想要的是在client阶段设置FTP-server的连接超时
使用 java-code
示例:
如果我查看 FTP 服务器的 vsftpd.conf 设置文件,
有一个idle_session_timeout=600
设置
我想知道这个空闲超时是否可以由 FTP-client 使用 java 代码
控制
下面的方法,我试过了,但不是很有效
FTPClient.setControlKeepAliveTimeout(sec);
FTPClient.setConnectTimeout(ms);
FTPClient.setDataTimeout(ms);
FTPClient.connect();
FTPClient.setSoTimeout(ms);
请帮帮我:)
FTP 客户端无法控制 FTP 服务器的设置。
但是你问的看起来更像是一个 XY problem 其中 X 可能是你想阻止服务器关闭空闲连接 Y 是你想出的解决方案的想法:控制服务器从客户端超时。只是,这个解决方案行不通。
相反,您需要解决服务器关闭连接的真正原因:因为没有来自客户端的 activity。这个问题可以简单地通过客户端与服务器交互来解决。这种方式甚至是documented。引用:
You should keep in mind that the FTP server may choose to prematurely close a connection if the client has been idle for longer than a given time period (usually 900 seconds). ... You may avoid server disconnections while the client is idle by periodically sending NOOP commands to the server.
我在 Java
中使用 Apache Commons-Net 库我想要的是在client阶段设置FTP-server的连接超时 使用 java-code
示例:
如果我查看 FTP 服务器的 vsftpd.conf 设置文件,
有一个idle_session_timeout=600
设置
我想知道这个空闲超时是否可以由 FTP-client 使用 java 代码
控制下面的方法,我试过了,但不是很有效
FTPClient.setControlKeepAliveTimeout(sec);
FTPClient.setConnectTimeout(ms);
FTPClient.setDataTimeout(ms);
FTPClient.connect();
FTPClient.setSoTimeout(ms);
请帮帮我:)
FTP 客户端无法控制 FTP 服务器的设置。
但是你问的看起来更像是一个 XY problem 其中 X 可能是你想阻止服务器关闭空闲连接 Y 是你想出的解决方案的想法:控制服务器从客户端超时。只是,这个解决方案行不通。
相反,您需要解决服务器关闭连接的真正原因:因为没有来自客户端的 activity。这个问题可以简单地通过客户端与服务器交互来解决。这种方式甚至是documented。引用:
You should keep in mind that the FTP server may choose to prematurely close a connection if the client has been idle for longer than a given time period (usually 900 seconds). ... You may avoid server disconnections while the client is idle by periodically sending NOOP commands to the server.