Q:

ANT FTP upload file: 425 Unable to build data connection: Connection timed out

I try to automate the deployment of a small site via ANT FTP. I use Win7-64bit and what started as an easy task gets more and more a challenge.
I first figured out that I had to install additional classes which I did. commons-net-3.0.1.jar, jakarta-oro-2.0.8.jar Then I had to deactivate parts of my firewall which I also did. netsh advfirewall set global StatefulFTP disable But even now it is not working.
But step by step, that is the task:
<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>

Thats the result:
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

What the heck did I do wrong?
UPDATE found a working example for Zend auto-sync seams ANT 1.8.3 has new features:
<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>

A:

I suspect that you still have a firewall issue.
Where FTP goes through a firewall, it is generally helpful to use passive mode.
Many FTP clients (Filezilla to take one example of many) default to passive mode.
The Ant FTP Task defaults to active mode:

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

Try using passive="yes" in your Ant FTP task.
Quite a good explanation 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.

I'm no firewall expect, but I think that the command you executed to configure your firewall (netsh advfirewall set global StatefulFTP disable) is what you would do if you wanted to run an FTP server on your Windows box behind a firewall. In your case, I think you are connecting from Windows as a client to a remote FTP server, so I think you could undo that command.

