apache/seatunnel · warning
Logout failed while disconnecting, error code -
Error message
Logout failed while disconnecting, error code -
What it means
SeaTunnelFTPFileSystem.disconnect logs this warning when FTPClient.logout() returns false, i.e. the FTP server replied with a non-success code (exposed via client.getReplyCode()). It is only logged — the underlying operation already completed, and disconnect must not turn a successful file operation into a failure.
Source
Thrown at seatunnel-connectors-v2/connector-file/connector-file-ftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/ftp/system/SeaTunnelFTPFileSystem.java:261
client.enterLocalActiveMode();
break;
}
}
/**
* Logout and disconnect the given FTPClient. *
*
* @param client FTPClient
*/
void disconnect(FTPClient client) {
if (client == null || !client.isConnected()) {
return;
}
try {
boolean logoutSuccess = client.logout();
if (!logoutSuccess) {
LOG.warn(
"Logout failed while disconnecting, error code - " + client.getReplyCode());
}
} catch (IOException e) {
// Some FTP servers close the control connection before responding to QUIT. The
// preceding operation has already completed, so do not turn a successful operation
// into a failure while releasing the connection.
LOG.warn("Failed to logout from FTP server while disconnecting", e);
} finally {
if (client.isConnected()) {
try {
client.disconnect();
} catch (IOException e) {
LOG.warn("Failed to disconnect from FTP server", e);
}
}
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Safe to ignore in most cases — verify the preceding file operation succeeded
- Increase FTP server idle timeout or client keep-alive so the control connection stays alive
- Check the reply code in the message against FTP semantics (421 = connection closed by server)
- Use explicit client.disconnect() in a finally block to guarantee socket cleanup
Defensive patterns
Strategy: try-catch
Validate before calling
// Before disconnect, check the control connection is alive
if (client == null || !client.isConnected()) { return; } Try / catch
try { fs.disconnect(); } catch (IOException e) { log.debug("ftp disconnect failed (non-fatal)", e); } // reply-code warnings are expected on dropped connections Prevention
- Keep FTP server idle timeouts above job duration between operations
- Call disconnect() in a finally block; never let it mask a successful operation
- Map reply codes (421 etc.) to reconnect instead of abort
When it happens
Trigger: logout() returns false during disconnect (called from open/create/close/delete/listStatus/getFileStatus teardown), e.g. because the control connection was already closed by the server or the session was in an unexpected state.
Common situations: FTP server closing idle control connections before QUIT; proxies/firewalls dropping the control channel; FTP server policies rejecting LOGOUT after an error reply; passive-mode connection reuse issues.
Related errors
- close easysearch connection error
- close elasticsearch connection error
- CLOSE_CONNECTION_FAILED
- WRITER_CLOSE_FAILED
- Unable to delete directory " + localFileDir
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/febed6a6dd1194db.
Report an issue: GitHub.