gpt4 book ai didi

ANT FTP上传文件: 425 Unable to build data connection: Connection timed out

转载 作者:行者123 更新时间:2023-12-02 00:32:34 25 4
gpt4 key购买 nike

我尝试通过 ANT FTP 自动部署小型站点。我使用 Win7-64 位,一开始是一项简单的任务,但现在变得越来越具有挑战性。我首先发现我必须安装额外的类,我也这样做了。 commons-net-3.0.1.jar, jakarta-oro-2.0.8.jar 然后我不得不停用部分防火墙,我也这样做了。 netsh advfirewall 设置全局 StatefulFTP 禁用但即使现在它也不起作用。

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

<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 通过防火墙时,使用 passive mode 通常会很有帮助。 .

许多 FTP 客户端(Filezilla 就是其中之一)默认为被动模式。

Ant FTP Task默认为事件模式:

passive selects passive-mode ("yes") transfers, for better through-firewall connectivity, at the price of performance. Defaults to "no"

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

很好的解释here :

425 Unable to build data connection: Connection timed out

This error can happen when trying to transfer a file or list a directory in Active (PORT) mode. The problem is usually solved by switching to Passive mode...

Explanation of the problem: In Active mode, the data connection is setup like this: The client sends a PORT command telling the server the port where it will be listening for the data connection. The server receives the PORT command and initiates a connection to the client's IP/port. However, if a firewall is blocking the incoming connection, then it will go unanswered, and the server will timeout waiting for the connection to be accepted.

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

关于ANT FTP上传文件: 425 Unable to build data connection: Connection timed out,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8015807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com