{"record":{"id":"febed6a6dd1194db","repo":"apache/seatunnel","slug":"logout-failed-while-disconnecting-error-code","errorCode":null,"errorMessage":"Logout failed while disconnecting, error code - ","messagePattern":"Logout failed while disconnecting, error code - ","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":261,"sourceCode":"                client.enterLocalActiveMode();\n                break;\n        }\n    }\n\n    /**\n     * Logout and disconnect the given FTPClient. *\n     *\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","sourceCodeStart":243,"sourceCodeEnd":279,"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#L243-L279","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before disconnect, check the control connection is alive\nif (client == null || !client.isConnected()) { return; }","typeGuard":null,"tryCatchPattern":"try { fs.disconnect(); } catch (IOException e) { log.debug(\"ftp disconnect failed (non-fatal)\", e); } // reply-code warnings are expected on dropped connections","preventionTips":["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"],"tags":["ftp","logout","connection-close","cleanup"],"backgroundTag":"connection-closed-early","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}