在服务器中有多个网卡,默认的路由不是当前的ftp服务器走的路由。
修改ftpclinent.java 中的代码实现。
protected Socket _openDataConnection_(String command, String arg) throws IOException {
if (__dataConnectionMode != ACTIVE_LOCAL_DATA_CONNECTION_MODE
&& __dataConnectionMode != PASSIVE_LOCAL_DATA_CONNECTION_MODE) {
return null;
}
final boolean isInet6Address = getRemoteAddress() instanceof Inet6Address;
Socket socket;
if (__dataConnectionMode == ACTIVE_LOCAL_DATA_CONNECTION_MODE) {
// if no activePortRange was set (correctly) -> getActivePort() = 0
// -> new ServerSocket(0) -> bind to any free local port
ServerSocket server = _serverSocketFactory_.createServerSocket(getActivePort(), 1, getHostAddress());
try {
// Try EPRT only if remote server is over IPv6, if not use PORT,
// be