apache/seatunnel · warning

Failed to disconnect from FTP server

Error message

Failed to disconnect from FTP server

What it means

In disconnect()'s finally block, the physical disconnect() call on a still-connected FTPClient threw an IOException. Like the logout warning, this is swallowed and logged at WARN because the session is being discarded anyway; the connection release cannot fail the enclosing operation.

Solutions

  1. No action needed — the exception is intentionally logged at WARN; the connection object is abandoned afterward and garbage collected.
  2. If sockets accumulate (fd leak), confirm this is the only disconnect path and check whether clients are shared across threads.
  3. Investigate network middleboxes (NAT/firewall) that may be dropping idle control connections abruptly; enable keep-alive or reduce session idle time.
Defensive patterns

Strategy: try-catch

Try / catch

// Same swallow-and-log pattern the connector uses:
if (client.isConnected()) {
    try {
        client.disconnect();
    } catch (IOException e) {
        LOG.warn("Failed to disconnect from FTP server (non-fatal)", e);
    }
}

Prevention

When it happens

Trigger: client.isConnected() is still true in the finally block after logout failed, and the subsequent client.disconnect() raises IOException — e.g. the socket is already half-closed by the server, a reset (RST) arrives, or the underlying socket is in an inconsistent state.

Common situations: Server forcefully reset the connection (connection reset) before the client could close it; half-open TCP connection after a network drop; double-close races in pooled/reused clients; FTP server crash during session teardown.

Related errors


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

Appendix: source

Thrown at seatunnel-connectors-v2/connector-file/connector-file-ftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/ftp/system/SeaTunnelFTPFileSystem.java:274

        }

        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);
                }
            }
        }
    }

    /**
     * Resolve against given working directory. *
     *
     * @param workDir workDir
     * @param path path
     * @return Path
     */
    private Path makeAbsolute(Path workDir, Path path) {
        if (path.isAbsolute()) {
            String filePath = path.toUri().getPath();
            if (filePath.equals("/")) {
                return workDir;
            }

View on GitHub (pinned to cf67b549a7)