Gradle ant ftp错误: "425 Connection timed out"

标签 gradle ant upload ftp

我的 gradle 构建脚本有问题:

apply plugin: 'java'

/*
 * Sources:
 * http://stackoverflow.com/q/17201815/4490015
 * https://github.com/Vazkii/Botania/blob/master/build.gradle
 */

repositories {
    mavenCentral()
}

configurations {
    ftpAntTask
}

/*
 * Load configuration file.
 */
ext.priv = parseConfig(file('private.properties'))

/*
 * Some project properties
 */
version = '0.0.1'
group = 'randers.notenoughvocab'
archivesBaseName = 'NotEnoughVocab'

dependencies {
    ftpAntTask('org.apache.ant:ant-commons-net:1.8.4') {
        module('commons-net:commons-net:1.4.1') {
            dependencies 'oro:oro:2.0.8:jar'
        }
    }
}

void ftp(Map args, Closure antFileset = {}) {
    ant {
        taskdef(name: 'ftp',
                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
                classpath: configurations.ftpAntTask.asPath)
        Map ftpArgs = args + [ //some default options
                               verbose : 'yes',
                               server  : priv.host,
                               userid  : priv.user,
                               password: priv.pass
        ]
        delegate.ftp(ftpArgs) {
            antFileset.delegate = delegate
            antFileset()
        }
    }
}

def parseConfig(File config) {
    config.withReader {
        def prop = new Properties()
        prop.load(it)
        return (new ConfigSlurper().parse(prop))
    }
}

/**
 * Uploads the javadoc to the server specified in private.properties
 */
task('uploadJavadoc', dependsOn: 'javadoc') << {
    ftp(action: 'send') {
        fileset(dir: 'build/docs/javadoc')
    }
}

jar {
    manifest {
        attributes 'Main-Class': 'randers.notenoughvocab.main.NotEnoughVocab'
    }
}

task('prepareBuild') {
    ant.replace(file: 'src/main/java/randers/notenoughvocab/main/Reference.java', token: '@VERSION@', value: version)
}

build.dependsOn(tasks.prepareBuild)

我收到以下错误消息:

could not put file: 425 Could not open data connection to port 55080: Connection timed out

显然它有效for others 。 我在 private.properties 中指定的服务器与 FileZilla 等 FTP 客户端配合良好,不会超时。我也尝试过使用本地 FTP 服务器进行相同的操作,但由于传输没有带宽限制,因此传输是即时的。
我可以做什么来防止超时?我应该关心端口 55080 吗?

我之前还进行了一些调试,并确保 priv.hostpriv.userpriv.pass 变量包含正确的信息.

最佳答案

如果当您从家用计算机(通常经过 NAT 且没有公共(public)可路由 IP)启动程序时出现该错误,您可以尝试使用 FTP 被动模式。来自 Ant task您只需将 passive: 'yes' 添加到您的 ftpArgs 中即可。

FTP 是一个很奇怪的协议(protocol):为了下载和上传文件,服务器到客户端会打开另一个连接,这通常会让没有公共(public) IP 的家庭用户感到头疼。简单的解决方案称为“被动模式”

关于Gradle ant ftp错误: "425 Connection timed out",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30018446/

相关文章:

android - Android 库项目可以是单个项目(而不是多项目构建)吗?

android - 错误 :Cannot change dependencies of configuration ':app:_debugAnnotationProcessor' after it has been resolved

intellij-idea - IntelliJ 2016.3.4 中突然出现 java.lang.NoClassDefFoundError

android - 升级到Gradle 4.0.0版打破了R8代码缩减

javascript - 文件输入元素的更改事件

asp.net - VB.NET中YouTube DirectUpload的BackgroundWorker?

java - 使用 resourcecount 获取属性中的行数

java - JUnit Ant 任务不会输出到屏幕

BlackBerry:在 Ant 脚本中从 JAR 源文件创建 COD

WordPress 将媒体上传到帖子