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

  1. Safe to ignore in most cases — verify the preceding file operation succeeded
  2. Increase FTP server idle timeout or client keep-alive so the control connection stays alive
  3. Check the reply code in the message against FTP semantics (421 = connection closed by server)
  4. 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

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


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/febed6a6dd1194db. Report an issue: GitHub.