commons-net-3.3 ftpClient上传文件报错java.net.socketexception: connection timed out

        FTPClient ftpClient = new FTPClient();
        FileInputStream fileInputStream;

        try {
            ftpClient.connect(HOST);
            ftpClient.login(USER_NAME, PASSWORD);
            ftpClient.enterLocalPassiveMode();
            fileInputStream = new FileInputStream(reconciliationFile);
            Boolean isSuccess = ftpClient.storeFile("/" + PATH + "/" + reconciliationFile.getName(), fileInputStream);

            logger.info("上传取暖对账文件结果:{}",isSuccess.toString());

            reconciliationFile.deleteOnExit();

            return true;
        } catch (IOException e) {
            logger.info(e.getMessage(), e);
            throw new RuntimeException("FTP客户端出错!", e);
        }

    }

如果没有

ftpClient.enterLocalPassiveMode();

将会抛出异常java.net.socketexception: connection timed out
或者isSuccess的将为false;

你可能感兴趣的:(commons-net-3.3 ftpClient上传文件报错java.net.socketexception: connection timed out)