Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ANT FTP上载文件:425无法建立数据连接:连接超时_Ant_Ftp - Fatal编程技术网

ANT FTP上载文件:425无法建立数据连接:连接超时

ANT FTP上载文件:425无法建立数据连接:连接超时,ant,ftp,Ant,Ftp,我尝试通过ANT FTP自动部署一个小型站点。我使用Win7-64位,开始时简单的任务变得越来越困难。 我首先发现我必须安装额外的类,我确实这么做了commons-net-3.0.1.jar,jakarta-oro-2.0.8.jar然后我不得不停用部分防火墙,我也这么做了netsh advfirewall set global StatefulFTP disable但即使现在它也不工作 但是一步一步地,这就是任务: <target name="ftp" description="">

我尝试通过ANT FTP自动部署一个小型站点。我使用Win7-64位,开始时简单的任务变得越来越困难。 我首先发现我必须安装额外的类,我确实这么做了
commons-net-3.0.1.jar,jakarta-oro-2.0.8.jar
然后我不得不停用部分防火墙,我也这么做了
netsh advfirewall set global StatefulFTP disable
但即使现在它也不工作

但是一步一步地,这就是任务:

<target name="ftp" description="">
<ftp server="${ftp.server}"
     userid="${ftp.user}"
     password="${ftp.password}"
     verbose="yes">
    <fileset dir="..">
        <include name="maintenance.php"/>
    </fileset>
</ftp>
</target>
ftp:
  [ftp] sending files
  [ftp] transferring C:\xampp\htdocs\maintenance.php

BUILD FAILED
C:\xampp\htdocs\xdf\build.xml:32: could not put file: 425 Unable to build data con
nection: Connection timed out


Total time: 3 minutes 10 seconds
我到底做错了什么

更新发现Zend自动同步的一个工作示例,ANT 1.8.3具有新功能:

<property name="ftp.server" value="ftp.foo.bar"/>
<property name="ftp.user" value="foor"/>
<property name="ftp.password" value="bar"/>
<property name="ftp.basedir" value=""/>
<property name="ftp.verbose" value="yes"/>

<target name="ftp-upload" description="Synchronise to FTP">
        <!-- Create temp folder -->
    <tempfile prefix="ant-epp-" destdir="${java.io.tmpdir}" property="temp.file"/>
    <mkdir dir="${temp.file}"/>

        <!-- Move, rename, upload, delete 'maintenance.php' -->
    <copy file="docs/hosting/maintenance.php" tofile="${temp.file}/index.php" />
    <ftp server="${ftp.server}"
            userid="${ftp.user}"
            password="${ftp.password}"
            remotedir="${ftp.basedir}/public"
            passive="yes"
            binary="yes"
            verbose="${ftp.verbose}">
        <fileset dir="${temp.file}">
            <include name="index.php" />
        </fileset>
    </ftp>
    <delete dir="${temp.file}" />

        <!-- Remove 'application' & Reupload -->
    <ftp action="del" server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}"
            remotedir="${ftp.basedir}/application" passive="yes" binary="yes" verbose="${ftp.verbose}">
        <fileset>
            <include name="**" />
        </fileset>
    </ftp>
    <ftp action="rmdir" server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}"
            remotedir="${ftp.basedir}/application" passive="yes" binary="yes" verbose="${ftp.verbose}">
        <fileset>
            <include name="**" />
        </fileset>
    </ftp>
    <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}"
            remotedir="${ftp.basedir}/application" passive="yes" binary="yes" verbose="${ftp.verbose}">
        <fileset dir="application" />
    </ftp>

        <!-- Replace 'index.php' -->
    <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}"
            remotedir="${ftp.basedir}/public" passive="yes" binary="yes" verbose="${ftp.verbose}">
        <fileset dir="public">
            <include name="index.php" />
        </fileset>
    </ftp>
</target>

我怀疑您仍然存在防火墙问题

当FTP通过防火墙时,使用它通常是有帮助的

许多FTP客户端(举个例子,Filezilla)默认为被动模式

默认为活动模式:

被动选择被动模式(“是”)传输,以获得更好的效果 通过防火墙连接,以性能为代价。默认值 “不”

尝试在Ant FTP任务中使用
passive=“yes”

这是一个很好的解释:

425无法建立数据连接:连接超时

尝试传输文件或列表时可能会发生此错误 目录处于活动(端口)模式。这个问题通常通过以下方法解决: 切换到被动模式

问题说明:在活动模式下,数据连接被断开 设置如下:客户端发送一个端口命令,通知服务器 它将侦听数据连接的端口。这个 服务器接收端口命令并启动到的连接 客户端的IP/端口。但是,如果防火墙正在阻止传入的 连接,则它将无法应答,服务器将超时 正在等待连接被接受


我不是防火墙,但我认为,如果您想在防火墙后面的Windows机箱上运行FTP服务器,您会执行配置防火墙的命令(
netsh advfirewall set global StatefulFTP disable
)。在您的情况下,我认为您是作为客户端从Windows连接到远程FTP服务器,因此我认为您可以撤消该命令。

是否可以与任何其他第三方程序进行FTP连接?本来不打算使用其他程序,但由于我的沮丧程度,我现在考虑使用PHP脚本。因为这是一个基于PHP的项目。我同意@FailedDev,你应该尝试使用另一个工具(比如FileZilla)来获取文件。FailedDev说,这是解决问题的经典方法。由于Ant中的FTP任务不起作用,您应该检查其他FTP软件是否起作用。如果它们有效,那么试着检查一下Ant和FTP之间的区别(比如你的防火墙是如何对待它们的)。谢谢各位,我尝试了这个allready WinSCP的工作方式,我的第二种方法在一定程度上有效。所以这不是gernerel FTP的问题。它与ANT或系统有关。谢谢,它正在工作!如果我能正确理解这项技术,我现在可以再次激活防火墙了?很高兴它能工作。我已经更新了我对您问题的回答。即使我使用被动模式,也需要seam
netsh advfirewall set global StatefulFTP disable
。只是想澄清一下。