apache/hadoop · warning · FTPException
Client not connected
Error message
Client not connected
What it means
disconnect() runs at the end of every FTPFileSystem operation to log out and close the session. If the client object exists but its control connection is already dead, logout is impossible and this FTPException (an IOException subclass) propagates out of whichever API was cleaning up.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java:251
client.enterRemotePassiveMode();
} else {
if (!upper.equals("ACTIVE_LOCAL_DATA_CONNECTION_MODE")) {
LOG.warn("Cannot parse the value for " + FS_FTP_DATA_CONNECTION_MODE
+ ": " + mode + ". Using default.");
}
}
}
/**
* Logout and disconnect the given FTPClient. *
*
* @param client
* @throws IOException
*/
private void disconnect(FTPClient client) throws IOException {
if (client != null) {
if (!client.isConnected()) {
throw new FTPException("Client not connected");
}
boolean logoutSuccess = client.logout();
client.disconnect();
if (!logoutSuccess) {
LOG.warn("Logout failed while disconnecting, error code - "
+ client.getReplyCode());
}
}
}
/**
* Resolve against given working directory. *
*
* @param workDir
* @param path
* @return
*/
private Path makeAbsolute(Path workDir, Path path) {View on GitHub (pinned to 2add963021)
Solutions
- Treat it as a symptom: find why the connection died (FTP server logs, firewall/idle timeouts), not the disconnect itself
- Keep control sessions alive: raise fs.ftp.timeout (used as the control keep-alive timeout) or finish transfers faster
- Retry the operation — FTPFileSystem opens a fresh connection per call, so a retry gets a clean session
- Wrap calls so cleanup exceptions do not mask the primary failure (close quietly, rethrow the original)
Defensive patterns
Strategy: try-catch
Try / catch
// keep cleanup exceptions from masking the primary failure
IOException primary = null;
try {
result = callFtpApi(fs);
} catch (IOException e) {
primary = e;
} finally {
if (primary != null) throw primary;
}
// 'Client not connected' during cleanup: log and retry the operation once Prevention
- Close each FTP stream exactly once; do not mix explicit disconnects with stream closes
- Keep fs.ftp.timeout aligned with (or above) the server's idle timeout so sessions survive to cleanup
- Treat this as a connection-stability symptom and retry the operation on a fresh session
When it happens
Trigger: The FTP server dropped the control connection (idle timeout, restart, firewall/NAT teardown) before the operation finished and disconnect() ran; double-disconnect paths where a stream close already tore down the session and the outer cleanup runs again.
Common situations: Long transfers exceeding server idle timeouts; NAT/firewall connection tracking expiring; the exception surfaces from an unrelated API call because it happens during cleanup, masking the original problem.
Related errors
- Failed to delete temporary files while closing stream: '%s'
- Failed to delete %s objects, detail: %s
- Har: delete not allowed
- Directory " + f.toString() + " is not empty
- Invalid host specified
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/e67d0f6c45f811a3.
Report an issue: GitHub.