You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Zac Heismann (JIRA)" <ji...@apache.org> on 2008/03/03 21:52:50 UTC

[jira] Created: (NET-192) Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"

Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
--------------------------------------------------------------------------------------------

                 Key: NET-192
                 URL: https://issues.apache.org/jira/browse/NET-192
             Project: Commons Net
          Issue Type: Bug
    Affects Versions: 1.4
         Environment: commons-net-1.4.1, Java 1.5.0_u10
Windows XP client, Solaris 10 server





            Reporter: Zac Heismann


Existing code working on Solaris 8, breaks under Solaris 10.  

We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
http://forums.ni.com/ni/board/message?board.id=180&message.id=30183

>From the man page:

  flush-wait yes|no [typelist]

         Controls the behavior at the end of a download or direc-
         tory  listing.  If yes, shutdown the data connection for
         sending and wait for the client to close its end  before
         sending a transfer complete reply on the control connec-
         tion. This is the default behavior.  If  no,  close  the
         data  connection  and  send  the transfer complete reply
         without waiting for the client. With this behavior, data
         loss can go undetected.

         If a client hangs at the end of a directory listing,  or
         the system has many sockets in the FIN_WAIT_2 state, try
         setting  to  no  as  a  workaround  for  broken   client
         behavior.


-----------
I'll attempt to attach a test case (you'll need to configure some properties though).

Here's the code being executed.  The execution hangs when the FTPClient.completePendingCommand() method is called for around 20 minutes and then the following Reply String is returned from the FTPClient: "426 Data connection: Error 0."

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

/**
 * Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
 * 
 * commons-net-1.4.1, Java 1.5.0_u10
 * Windows XP client, Solaris 10 server
 * 
Existing code working on Solaris 8, breaks under Solaris 10.  

We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
http://forums.ni.com/ni/board/message?board.id=180&message.id=30183

>From the man page:

  flush-wait yes|no [typelist]

         Controls the behavior at the end of a download or direc-
         tory  listing.  If yes, shutdown the data connection for
         sending and wait for the client to close its end  before
         sending a transfer complete reply on the control connec-
         tion. This is the default behavior.  If  no,  close  the
         data  connection  and  send  the transfer complete reply
         without waiting for the client. With this behavior, data
         loss can go undetected.

         If a client hangs at the end of a directory listing,  or
         the system has many sockets in the FIN_WAIT_2 state, try
         setting  to  no  as  a  workaround  for  broken   client
         behavior.

 * 
 * @author zheismann
 */
public final class App 
{
    
    public static void testFTP(String ftpHost, String ftpUserName, String ftpPassword, 
                               String fileToDownload, String localDestinationFile)
        throws Exception
    {
        File localFile = new File( localDestinationFile );
        FTPClient ftpClient = setupConnection(ftpHost, ftpUserName, ftpPassword);

        ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
        System.out.println("Attempting to download '" + fileToDownload + "' from host: " + ftpHost);
        System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
        FileOutputStream outStream = new FileOutputStream( localFile );

        InputStream ftpIn = ftpClient.retrieveFileStream( fileToDownload );

        InputStream tempStream = new BufferedInputStream( ftpIn );

        byte[] buf = new byte[ftpClient.getBufferSize()];
        int len;

        //Read from the ftpStream and write to the local file
        while ( (len = tempStream.read( buf )) >= 0 )
        {
            outStream.write( buf, 0, len );
        }

        if ( !ftpClient.completePendingCommand() )
        {
            throw new Exception(
                "Error downloading file: " +
                localDestinationFile + "\n" +
                ftpClient.getReplyString() + "\n" );
        }
        System.out.println("Success!");
    }
    
    private static FTPClient setupConnection(String ftpHost, String ftpUserName, String ftpPassword) throws Exception
    {
        FTPClient ftpClient = new FTPClient();
        ftpClient.connect(ftpHost);
        ftpClient.login(ftpUserName, ftpPassword);
        int reply = ftpClient.getReplyCode();
        if (!FTPReply.isPositiveCompletion(reply))
        {
            throw new Exception( "Error connecting to: " + ftpHost + "\n" + ftpClient.getReplyString() + "\n" );
        }
        return ftpClient;
    }


public class App 
{
    private static final String FTP_HOST = "";
    private static final String FTP_USERNAME = "zheisman";
    private static final String FTP_PASSWORD = "";
    private static final String FILE_TO_DOWNLOAD = "/home/zheisman/pom.xml";
    private static final String FTP_FILE_DESTINATION = "/pom.xml";
    
    private static void testFTP() throws Exception
    {
        File localFile = new File( FTP_FILE_DESTINATION );
        FTPClient ftpClient = setupConnection();

        ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
        System.out.println("Attempting to download '" + FILE_TO_DOWNLOAD + "' from host: " + FTP_HOST);
        System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
        FileOutputStream outStream = new FileOutputStream( localFile );

        InputStream ftpIn = ftpClient.retrieveFileStream( FILE_TO_DOWNLOAD );

        InputStream tempStream = new BufferedInputStream( ftpIn );

        byte[] buf = new byte[ftpClient.getBufferSize()];
        int len;

        //Read from the ftpStream and write to the local file
        while ( (len = tempStream.read( buf )) >= 0 )
        {
            outStream.write( buf, 0, len );
        }

        if ( !ftpClient.completePendingCommand() )
        {
            throw new Exception(
                "Error downloading file: " +
                FILE_TO_DOWNLOAD + "\n" +
                ftpClient.getReplyString() + "\n" );
        }
    }
    
    private static FTPClient setupConnection() throws Exception
    {
        FTPClient ftpClient = new FTPClient();
        ftpClient.connect(FTP_HOST);
        ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
        int reply = ftpClient.getReplyCode();
        if (!FTPReply.isPositiveCompletion(reply))
        {
            throw new Exception( "Error connecting to: " + FTP_HOST + "\n" + ftpClient.getReplyString() + "\n" );
        }
        return ftpClient;
    }

    
    public static void main( String[] args )
    {
        try
        {
            testFTP();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (NET-192) Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"

Posted by "Rory Winston (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/NET-192?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rory Winston closed NET-192.
----------------------------

    Resolution: Cannot Reproduce

Need something reproducible here - the only differential is the Solaris version, which leads me to think that this may be a server rather than a client issue.

> Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
> --------------------------------------------------------------------------------------------
>
>                 Key: NET-192
>                 URL: https://issues.apache.org/jira/browse/NET-192
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: commons-net-1.4.1, Java 1.5.0_u10
> Windows XP client, Solaris 10 server
>            Reporter: Zac Heismann
>         Attachments: FTPTest.zip
>
>
> Existing code working on Solaris 8, breaks under Solaris 10.  
> We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
> http://forums.ni.com/ni/board/message?board.id=180&message.id=30183
> From the man page:
>   flush-wait yes|no [typelist]
>          Controls the behavior at the end of a download or direc-
>          tory  listing.  If yes, shutdown the data connection for
>          sending and wait for the client to close its end  before
>          sending a transfer complete reply on the control connec-
>          tion. This is the default behavior.  If  no,  close  the
>          data  connection  and  send  the transfer complete reply
>          without waiting for the client. With this behavior, data
>          loss can go undetected.
>          If a client hangs at the end of a directory listing,  or
>          the system has many sockets in the FIN_WAIT_2 state, try
>          setting  to  no  as  a  workaround  for  broken   client
>          behavior.
> -----------
> I'll attempt to attach a test case (you'll need to configure some properties though).
> Here's the code being executed.  The execution hangs when the FTPClient.completePendingCommand() method is called for around 20 minutes and then the following Reply String is returned from the FTPClient: "426 Data connection: Error 0."
> import java.io.BufferedInputStream;
> import java.io.File;
> import java.io.FileOutputStream;
> import java.io.InputStream;
> import org.apache.commons.net.ftp.FTP;
> import org.apache.commons.net.ftp.FTPClient;
> import org.apache.commons.net.ftp.FTPReply;
> /**
>  * Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
>  * 
>  * commons-net-1.4.1, Java 1.5.0_u10
>  * Windows XP client, Solaris 10 server
>  * 
> Existing code working on Solaris 8, breaks under Solaris 10.  
> We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
> http://forums.ni.com/ni/board/message?board.id=180&message.id=30183
> From the man page:
>   flush-wait yes|no [typelist]
>          Controls the behavior at the end of a download or direc-
>          tory  listing.  If yes, shutdown the data connection for
>          sending and wait for the client to close its end  before
>          sending a transfer complete reply on the control connec-
>          tion. This is the default behavior.  If  no,  close  the
>          data  connection  and  send  the transfer complete reply
>          without waiting for the client. With this behavior, data
>          loss can go undetected.
>          If a client hangs at the end of a directory listing,  or
>          the system has many sockets in the FIN_WAIT_2 state, try
>          setting  to  no  as  a  workaround  for  broken   client
>          behavior.
>  * 
>  * @author zheismann
>  */
> public final class App 
> {
>     
>     public static void testFTP(String ftpHost, String ftpUserName, String ftpPassword, 
>                                String fileToDownload, String localDestinationFile)
>         throws Exception
>     {
>         File localFile = new File( localDestinationFile );
>         FTPClient ftpClient = setupConnection(ftpHost, ftpUserName, ftpPassword);
>         ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
>         System.out.println("Attempting to download '" + fileToDownload + "' from host: " + ftpHost);
>         System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
>         FileOutputStream outStream = new FileOutputStream( localFile );
>         InputStream ftpIn = ftpClient.retrieveFileStream( fileToDownload );
>         InputStream tempStream = new BufferedInputStream( ftpIn );
>         byte[] buf = new byte[ftpClient.getBufferSize()];
>         int len;
>         //Read from the ftpStream and write to the local file
>         while ( (len = tempStream.read( buf )) >= 0 )
>         {
>             outStream.write( buf, 0, len );
>         }
>         if ( !ftpClient.completePendingCommand() )
>         {
>             throw new Exception(
>                 "Error downloading file: " +
>                 localDestinationFile + "\n" +
>                 ftpClient.getReplyString() + "\n" );
>         }
>         System.out.println("Success!");
>     }
>     
>     private static FTPClient setupConnection(String ftpHost, String ftpUserName, String ftpPassword) throws Exception
>     {
>         FTPClient ftpClient = new FTPClient();
>         ftpClient.connect(ftpHost);
>         ftpClient.login(ftpUserName, ftpPassword);
>         int reply = ftpClient.getReplyCode();
>         if (!FTPReply.isPositiveCompletion(reply))
>         {
>             throw new Exception( "Error connecting to: " + ftpHost + "\n" + ftpClient.getReplyString() + "\n" );
>         }
>         return ftpClient;
>     }
> public class App 
> {
>     private static final String FTP_HOST = "";
>     private static final String FTP_USERNAME = "zheisman";
>     private static final String FTP_PASSWORD = "";
>     private static final String FILE_TO_DOWNLOAD = "/home/zheisman/pom.xml";
>     private static final String FTP_FILE_DESTINATION = "/pom.xml";
>     
>     private static void testFTP() throws Exception
>     {
>         File localFile = new File( FTP_FILE_DESTINATION );
>         FTPClient ftpClient = setupConnection();
>         ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
>         System.out.println("Attempting to download '" + FILE_TO_DOWNLOAD + "' from host: " + FTP_HOST);
>         System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
>         FileOutputStream outStream = new FileOutputStream( localFile );
>         InputStream ftpIn = ftpClient.retrieveFileStream( FILE_TO_DOWNLOAD );
>         InputStream tempStream = new BufferedInputStream( ftpIn );
>         byte[] buf = new byte[ftpClient.getBufferSize()];
>         int len;
>         //Read from the ftpStream and write to the local file
>         while ( (len = tempStream.read( buf )) >= 0 )
>         {
>             outStream.write( buf, 0, len );
>         }
>         if ( !ftpClient.completePendingCommand() )
>         {
>             throw new Exception(
>                 "Error downloading file: " +
>                 FILE_TO_DOWNLOAD + "\n" +
>                 ftpClient.getReplyString() + "\n" );
>         }
>     }
>     
>     private static FTPClient setupConnection() throws Exception
>     {
>         FTPClient ftpClient = new FTPClient();
>         ftpClient.connect(FTP_HOST);
>         ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
>         int reply = ftpClient.getReplyCode();
>         if (!FTPReply.isPositiveCompletion(reply))
>         {
>             throw new Exception( "Error connecting to: " + FTP_HOST + "\n" + ftpClient.getReplyString() + "\n" );
>         }
>         return ftpClient;
>     }
>     
>     public static void main( String[] args )
>     {
>         try
>         {
>             testFTP();
>         }
>         catch (Exception ex)
>         {
>             ex.printStackTrace();
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (NET-192) Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"

Posted by "Rory Winston (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574875#action_12574875 ] 

Rory Winston commented on NET-192:
----------------------------------

Do you have an FTP host that can be connected to? This cant be reproduced otherwise.

> Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
> --------------------------------------------------------------------------------------------
>
>                 Key: NET-192
>                 URL: https://issues.apache.org/jira/browse/NET-192
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: commons-net-1.4.1, Java 1.5.0_u10
> Windows XP client, Solaris 10 server
>            Reporter: Zac Heismann
>         Attachments: FTPTest.zip
>
>
> Existing code working on Solaris 8, breaks under Solaris 10.  
> We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
> http://forums.ni.com/ni/board/message?board.id=180&message.id=30183
> From the man page:
>   flush-wait yes|no [typelist]
>          Controls the behavior at the end of a download or direc-
>          tory  listing.  If yes, shutdown the data connection for
>          sending and wait for the client to close its end  before
>          sending a transfer complete reply on the control connec-
>          tion. This is the default behavior.  If  no,  close  the
>          data  connection  and  send  the transfer complete reply
>          without waiting for the client. With this behavior, data
>          loss can go undetected.
>          If a client hangs at the end of a directory listing,  or
>          the system has many sockets in the FIN_WAIT_2 state, try
>          setting  to  no  as  a  workaround  for  broken   client
>          behavior.
> -----------
> I'll attempt to attach a test case (you'll need to configure some properties though).
> Here's the code being executed.  The execution hangs when the FTPClient.completePendingCommand() method is called for around 20 minutes and then the following Reply String is returned from the FTPClient: "426 Data connection: Error 0."
> import java.io.BufferedInputStream;
> import java.io.File;
> import java.io.FileOutputStream;
> import java.io.InputStream;
> import org.apache.commons.net.ftp.FTP;
> import org.apache.commons.net.ftp.FTPClient;
> import org.apache.commons.net.ftp.FTPReply;
> /**
>  * Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
>  * 
>  * commons-net-1.4.1, Java 1.5.0_u10
>  * Windows XP client, Solaris 10 server
>  * 
> Existing code working on Solaris 8, breaks under Solaris 10.  
> We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
> http://forums.ni.com/ni/board/message?board.id=180&message.id=30183
> From the man page:
>   flush-wait yes|no [typelist]
>          Controls the behavior at the end of a download or direc-
>          tory  listing.  If yes, shutdown the data connection for
>          sending and wait for the client to close its end  before
>          sending a transfer complete reply on the control connec-
>          tion. This is the default behavior.  If  no,  close  the
>          data  connection  and  send  the transfer complete reply
>          without waiting for the client. With this behavior, data
>          loss can go undetected.
>          If a client hangs at the end of a directory listing,  or
>          the system has many sockets in the FIN_WAIT_2 state, try
>          setting  to  no  as  a  workaround  for  broken   client
>          behavior.
>  * 
>  * @author zheismann
>  */
> public final class App 
> {
>     
>     public static void testFTP(String ftpHost, String ftpUserName, String ftpPassword, 
>                                String fileToDownload, String localDestinationFile)
>         throws Exception
>     {
>         File localFile = new File( localDestinationFile );
>         FTPClient ftpClient = setupConnection(ftpHost, ftpUserName, ftpPassword);
>         ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
>         System.out.println("Attempting to download '" + fileToDownload + "' from host: " + ftpHost);
>         System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
>         FileOutputStream outStream = new FileOutputStream( localFile );
>         InputStream ftpIn = ftpClient.retrieveFileStream( fileToDownload );
>         InputStream tempStream = new BufferedInputStream( ftpIn );
>         byte[] buf = new byte[ftpClient.getBufferSize()];
>         int len;
>         //Read from the ftpStream and write to the local file
>         while ( (len = tempStream.read( buf )) >= 0 )
>         {
>             outStream.write( buf, 0, len );
>         }
>         if ( !ftpClient.completePendingCommand() )
>         {
>             throw new Exception(
>                 "Error downloading file: " +
>                 localDestinationFile + "\n" +
>                 ftpClient.getReplyString() + "\n" );
>         }
>         System.out.println("Success!");
>     }
>     
>     private static FTPClient setupConnection(String ftpHost, String ftpUserName, String ftpPassword) throws Exception
>     {
>         FTPClient ftpClient = new FTPClient();
>         ftpClient.connect(ftpHost);
>         ftpClient.login(ftpUserName, ftpPassword);
>         int reply = ftpClient.getReplyCode();
>         if (!FTPReply.isPositiveCompletion(reply))
>         {
>             throw new Exception( "Error connecting to: " + ftpHost + "\n" + ftpClient.getReplyString() + "\n" );
>         }
>         return ftpClient;
>     }
> public class App 
> {
>     private static final String FTP_HOST = "";
>     private static final String FTP_USERNAME = "zheisman";
>     private static final String FTP_PASSWORD = "";
>     private static final String FILE_TO_DOWNLOAD = "/home/zheisman/pom.xml";
>     private static final String FTP_FILE_DESTINATION = "/pom.xml";
>     
>     private static void testFTP() throws Exception
>     {
>         File localFile = new File( FTP_FILE_DESTINATION );
>         FTPClient ftpClient = setupConnection();
>         ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
>         System.out.println("Attempting to download '" + FILE_TO_DOWNLOAD + "' from host: " + FTP_HOST);
>         System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
>         FileOutputStream outStream = new FileOutputStream( localFile );
>         InputStream ftpIn = ftpClient.retrieveFileStream( FILE_TO_DOWNLOAD );
>         InputStream tempStream = new BufferedInputStream( ftpIn );
>         byte[] buf = new byte[ftpClient.getBufferSize()];
>         int len;
>         //Read from the ftpStream and write to the local file
>         while ( (len = tempStream.read( buf )) >= 0 )
>         {
>             outStream.write( buf, 0, len );
>         }
>         if ( !ftpClient.completePendingCommand() )
>         {
>             throw new Exception(
>                 "Error downloading file: " +
>                 FILE_TO_DOWNLOAD + "\n" +
>                 ftpClient.getReplyString() + "\n" );
>         }
>     }
>     
>     private static FTPClient setupConnection() throws Exception
>     {
>         FTPClient ftpClient = new FTPClient();
>         ftpClient.connect(FTP_HOST);
>         ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
>         int reply = ftpClient.getReplyCode();
>         if (!FTPReply.isPositiveCompletion(reply))
>         {
>             throw new Exception( "Error connecting to: " + FTP_HOST + "\n" + ftpClient.getReplyString() + "\n" );
>         }
>         return ftpClient;
>     }
>     
>     public static void main( String[] args )
>     {
>         try
>         {
>             testFTP();
>         }
>         catch (Exception ex)
>         {
>             ex.printStackTrace();
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (NET-192) Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"

Posted by "Zac Heismann (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/NET-192?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Zac Heismann updated NET-192:
-----------------------------

    Attachment: FTPTest.zip

Maven project of containing the code and its test case.

> Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
> --------------------------------------------------------------------------------------------
>
>                 Key: NET-192
>                 URL: https://issues.apache.org/jira/browse/NET-192
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: commons-net-1.4.1, Java 1.5.0_u10
> Windows XP client, Solaris 10 server
>            Reporter: Zac Heismann
>         Attachments: FTPTest.zip
>
>
> Existing code working on Solaris 8, breaks under Solaris 10.  
> We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
> http://forums.ni.com/ni/board/message?board.id=180&message.id=30183
> From the man page:
>   flush-wait yes|no [typelist]
>          Controls the behavior at the end of a download or direc-
>          tory  listing.  If yes, shutdown the data connection for
>          sending and wait for the client to close its end  before
>          sending a transfer complete reply on the control connec-
>          tion. This is the default behavior.  If  no,  close  the
>          data  connection  and  send  the transfer complete reply
>          without waiting for the client. With this behavior, data
>          loss can go undetected.
>          If a client hangs at the end of a directory listing,  or
>          the system has many sockets in the FIN_WAIT_2 state, try
>          setting  to  no  as  a  workaround  for  broken   client
>          behavior.
> -----------
> I'll attempt to attach a test case (you'll need to configure some properties though).
> Here's the code being executed.  The execution hangs when the FTPClient.completePendingCommand() method is called for around 20 minutes and then the following Reply String is returned from the FTPClient: "426 Data connection: Error 0."
> import java.io.BufferedInputStream;
> import java.io.File;
> import java.io.FileOutputStream;
> import java.io.InputStream;
> import org.apache.commons.net.ftp.FTP;
> import org.apache.commons.net.ftp.FTPClient;
> import org.apache.commons.net.ftp.FTPReply;
> /**
>  * Solaris 10 unable to download files, FTPClient timesout with: "426 Data connection: Error 0"
>  * 
>  * commons-net-1.4.1, Java 1.5.0_u10
>  * Windows XP client, Solaris 10 server
>  * 
> Existing code working on Solaris 8, breaks under Solaris 10.  
> We configured the ftpdaemon's flush-wait property to be set to no.  Here's some info on what we did:
> http://forums.ni.com/ni/board/message?board.id=180&message.id=30183
> From the man page:
>   flush-wait yes|no [typelist]
>          Controls the behavior at the end of a download or direc-
>          tory  listing.  If yes, shutdown the data connection for
>          sending and wait for the client to close its end  before
>          sending a transfer complete reply on the control connec-
>          tion. This is the default behavior.  If  no,  close  the
>          data  connection  and  send  the transfer complete reply
>          without waiting for the client. With this behavior, data
>          loss can go undetected.
>          If a client hangs at the end of a directory listing,  or
>          the system has many sockets in the FIN_WAIT_2 state, try
>          setting  to  no  as  a  workaround  for  broken   client
>          behavior.
>  * 
>  * @author zheismann
>  */
> public final class App 
> {
>     
>     public static void testFTP(String ftpHost, String ftpUserName, String ftpPassword, 
>                                String fileToDownload, String localDestinationFile)
>         throws Exception
>     {
>         File localFile = new File( localDestinationFile );
>         FTPClient ftpClient = setupConnection(ftpHost, ftpUserName, ftpPassword);
>         ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
>         System.out.println("Attempting to download '" + fileToDownload + "' from host: " + ftpHost);
>         System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
>         FileOutputStream outStream = new FileOutputStream( localFile );
>         InputStream ftpIn = ftpClient.retrieveFileStream( fileToDownload );
>         InputStream tempStream = new BufferedInputStream( ftpIn );
>         byte[] buf = new byte[ftpClient.getBufferSize()];
>         int len;
>         //Read from the ftpStream and write to the local file
>         while ( (len = tempStream.read( buf )) >= 0 )
>         {
>             outStream.write( buf, 0, len );
>         }
>         if ( !ftpClient.completePendingCommand() )
>         {
>             throw new Exception(
>                 "Error downloading file: " +
>                 localDestinationFile + "\n" +
>                 ftpClient.getReplyString() + "\n" );
>         }
>         System.out.println("Success!");
>     }
>     
>     private static FTPClient setupConnection(String ftpHost, String ftpUserName, String ftpPassword) throws Exception
>     {
>         FTPClient ftpClient = new FTPClient();
>         ftpClient.connect(ftpHost);
>         ftpClient.login(ftpUserName, ftpPassword);
>         int reply = ftpClient.getReplyCode();
>         if (!FTPReply.isPositiveCompletion(reply))
>         {
>             throw new Exception( "Error connecting to: " + ftpHost + "\n" + ftpClient.getReplyString() + "\n" );
>         }
>         return ftpClient;
>     }
> public class App 
> {
>     private static final String FTP_HOST = "";
>     private static final String FTP_USERNAME = "zheisman";
>     private static final String FTP_PASSWORD = "";
>     private static final String FILE_TO_DOWNLOAD = "/home/zheisman/pom.xml";
>     private static final String FTP_FILE_DESTINATION = "/pom.xml";
>     
>     private static void testFTP() throws Exception
>     {
>         File localFile = new File( FTP_FILE_DESTINATION );
>         FTPClient ftpClient = setupConnection();
>         ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
>         System.out.println("Attempting to download '" + FILE_TO_DOWNLOAD + "' from host: " + FTP_HOST);
>         System.out.println("to the localhost: '" + localFile.getAbsolutePath() + "'");
>         FileOutputStream outStream = new FileOutputStream( localFile );
>         InputStream ftpIn = ftpClient.retrieveFileStream( FILE_TO_DOWNLOAD );
>         InputStream tempStream = new BufferedInputStream( ftpIn );
>         byte[] buf = new byte[ftpClient.getBufferSize()];
>         int len;
>         //Read from the ftpStream and write to the local file
>         while ( (len = tempStream.read( buf )) >= 0 )
>         {
>             outStream.write( buf, 0, len );
>         }
>         if ( !ftpClient.completePendingCommand() )
>         {
>             throw new Exception(
>                 "Error downloading file: " +
>                 FILE_TO_DOWNLOAD + "\n" +
>                 ftpClient.getReplyString() + "\n" );
>         }
>     }
>     
>     private static FTPClient setupConnection() throws Exception
>     {
>         FTPClient ftpClient = new FTPClient();
>         ftpClient.connect(FTP_HOST);
>         ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
>         int reply = ftpClient.getReplyCode();
>         if (!FTPReply.isPositiveCompletion(reply))
>         {
>             throw new Exception( "Error connecting to: " + FTP_HOST + "\n" + ftpClient.getReplyString() + "\n" );
>         }
>         return ftpClient;
>     }
>     
>     public static void main( String[] args )
>     {
>         try
>         {
>             testFTP();
>         }
>         catch (Exception ex)
>         {
>             ex.printStackTrace();
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.