{"record":{"id":"596b69efd94efdd3","repo":"apache/seatunnel","slug":"failed-to-logout-from-ftp-server-while-disconnecti","errorCode":null,"errorMessage":"Failed to logout from FTP server while disconnecting","messagePattern":"Failed to logout from FTP server while disconnecting","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-file/connector-file-ftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/ftp/system/SeaTunnelFTPFileSystem.java","lineNumber":268,"sourceCode":"     *\n     * @param client FTPClient\n     */\n    void disconnect(FTPClient client) {\n        if (client == null || !client.isConnected()) {\n            return;\n        }\n\n        try {\n            boolean logoutSuccess = client.logout();\n            if (!logoutSuccess) {\n                LOG.warn(\n                        \"Logout failed while disconnecting, error code - \" + client.getReplyCode());\n            }\n        } catch (IOException e) {\n            // Some FTP servers close the control connection before responding to QUIT. The\n            // preceding operation has already completed, so do not turn a successful operation\n            // into a failure while releasing the connection.\n            LOG.warn(\"Failed to logout from FTP server while disconnecting\", e);\n        } finally {\n            if (client.isConnected()) {\n                try {\n                    client.disconnect();\n                } catch (IOException e) {\n                    LOG.warn(\"Failed to disconnect from FTP server\", e);\n                }\n            }\n        }\n    }\n\n    /**\n     * Resolve against given working directory. *\n     *\n     * @param workDir workDir\n     * @param path path\n     * @return Path\n     */","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-ftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/ftp/system/SeaTunnelFTPFileSystem.java#L250-L286","documentation":"During disconnect(), the client's logout() call threw an IOException (or returned false, which logs a related warning). The code deliberately logs this as a warning instead of propagating: some FTP servers close the control connection before replying to QUIT, and the preceding operation already completed. It is benign teardown noise, not a data-path failure.","triggerScenarios":"client.logout() raises IOException while releasing the FTPClient after open, create, close, delete, listStatus, or getFileStatus — usually because the server already dropped the control connection, the socket timed out, or the server rejected the QUIT command with an error reply.","commonSituations":"FTP server with a short idle timeout that closed the connection mid-operation; server that terminates the control channel immediately after the last data transfer; flaky network between client and server; server restarting during teardown.","solutions":["No action needed — this is logged at WARN by design and the code still calls disconnect() in the finally block; verify the actual read/write operation succeeded.","If it appears constantly, check server-side idle/session timeout settings and keep-alive configuration.","Ensure the control connection is not being dropped by an intermediate firewall/proxy between client and server.","Upgrade/inspect the FTP server if QUIT consistently fails with an error reply code (see the companion 'Logout failed ... error code' warning for the reply code)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The library already swallows this; mirror the pattern in your own FTP code:\ntry {\n    if (!client.logout()) {\n        LOG.warn(\"Logout failed, reply code: \" + client.getReplyCode());\n    }\n} catch (IOException e) {\n    LOG.warn(\"Failed to logout during teardown (non-fatal)\", e);\n} finally {\n    try { client.disconnect(); } catch (IOException ignored) { }\n}","preventionTips":["Treat logout/disconnect warnings during teardown as benign — check the success of the preceding read/write operation instead","Align server idle-timeout and client keep-alive settings to avoid dropped control connections","Monitor the companion 'Logout failed ... error code' warning for persistent server-side issues"],"tags":["ftp","disconnect","ioexception","teardown"],"backgroundTag":"broken-pipe","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}