Welcome to the Xceed Community | Help
Community Search  
More Search Options

FTP Synchronize terminate application

Page 1 of 2 (17 items)   1 2 Next >
Sort Posts: Previous Next
  •  05-08-2009, 2:28 AM Post no. 20818

    FTP Synchronize terminate application

    Hello,

    My application synchronize files from a NAS 24/7 every 2min. After X hours the application suddenly crashes/terminates. Sometimes we're able to log the exception that occurse but not always(strange). "Connection to the FTP server's data channel timed-out." The call to Synchronize is wrapped in try,catch blocks so i can't figure out why the application gets terminated other than some unhandled unmanagde stuff, our application don't use any. The application have been tested on 2 different FTP servers/ 2 different PC. It crasches on all configurations. On the server side it only logs sudden disconnects. Server and client is behind the same NAT so no firewall involved besides WinXP's.

     Regards Andreas

     Server log:

    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> 250 CWD successful. "/Cad_Files" is current directory.
    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> TYPE A
    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> 200 Type set to A
    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> PORT 192,168,10,175,12,56
    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> 200 Port command successful
    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> LIST
    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> 150 Opening data channel for directory list.
    (012374) 2009-05-02 09:48:06 - rtlaka (192.168.10.175)> 226 Transfer OK
    (012373) 2009-05-02 09:48:36 - rtlaka (192.168.10.175)> QUIT
    (012373) 2009-05-02 09:48:36 - rtlaka (192.168.10.175)> 221 Goodbye
    (012373) 2009-05-02 09:48:36 - rtlaka (192.168.10.175)> disconnected.
    (012374) 2009-05-02 09:48:36 - rtlaka (192.168.10.175)> disconnected.

    Exception:


    Error message:
    An error occurred while creating a folder.
    Type: Xceed.Ftp.FtpFolder
    FullName: \Cad_Files\
    Base exception:
    Connection to the FTP server's data channel timed-out.
    Stack trace:
       at Xceed.FileSystem.AbstractFolder.GetFolders(FileSystemEvents events, Object userData, Boolean recursive, Object[] filters)
       at Xceed.Synchronization.Synchronizer.SynchronizeFolder(SynchronizationEventsSession session, SynchronizationOptions options, Int32 masterItemIndex, FileSystemItem metaDataItem, Filter[] filters, IList folders, WorkArrayList workArrayList, WorkArrayList workIrrelevantItemIndexes, AbstractFolder folder, Int32 folderIndex, Hashtable processedContent, Boolean& abort)
       at Xceed.Synchronization.Synchronizer.SynchronizeFolders(SynchronizationEventsSession session, SynchronizationOptions options, Int32 masterFolderIndex, FileSystemItem metaDataItem, WorkArrayList folders, WorkArrayList workIrrelevantItemIndexes, Filter[] filters)
       at Xceed.Synchronization.Synchronizer.DoSynchronize(SynchronizationEventsSession session, SynchronizationOptions options, Int32 masterItemIndex, FileSystemItem metaDataItem, WorkArrayList workItems, WorkArrayList workIrrelevantItemIndexes, Filter[] filters)
       at Xceed.Synchronization.Synchronizer.Synchronize(FileSystemEvents fileSystemEvents, Object fileSystemEventsUserData, SynchronizationEvents synchronizationEvents, Object synchronizationEventsUserData, SynchronizationOptions options, Int32 masterItemIndex, FileSystemItem metaDataItem, IList items, IList irrelevantItemIndexes, Filter[] filters)
       at Xceed.Synchronization.Synchronizer.Synchronize(FileSystemEvents fileSystemEvents, Object fileSystemEventsUserData, SynchronizationEvents synchronizationEvents, Object synchronizationEventsUserData, FileSystemItem masterItem, SynchronizationOptions options, Filter[] filters, FileSystemItem[] items)
       at FtpSynchronizeHandler.classFtpSynchronizeHandler.SyncRemoteToLocal(FtpConnection udtLocalFtpConnection, SynchronizationEvents udtSynchronizationEvents, FtpSynchronizeItem udtSyncItem)
     

    FTP Connection snippet

           Try

                ...

                    Dim ipRBABANas As New IPAddress(bytIPAddress)
                    Dim ipEndP As New IPEndPoint(ipRBABANas, 21)
                    udtLocalFtpConnection = New FtpConnection(ipEndP, strUserName, strPassWord)
                    udtLocalFtpConnection.PassiveTransfer = False

                    'call DoSynchronizeStuff

            ...

            Catch ex As Exception
              ...

            Finally
                    ...
                    udtLocalFtpConnection.TraceWriter.Dispose()
                    udtLocalFtpConnection.Dispose()

            End Try

    Synchronize snippet

     

            Try

            ...

               ' Test connection before trying to use it
                udtLocalFtpConnection.TestConnection()

                ' Create folders to synchronize
                Dim udtLocalFolder As AbstractFolder = New DiskFolder(udtSyncItem.LocalPath)
                Dim udtRootFolder As New FtpFolder(udtLocalFtpConnection)
                Dim udtRemoteFolder As AbstractFolder = udtRootFolder.GetFolder(udtSyncItem.RemotePath)

                ' Synchronize one-way from the remote folder
                syncResult = Synchronizer.Synchronize(Nothing, Nothing, udtSynchronizationEvents, Nothing, udtRemoteFolder, _
                                                                           udtSyncItem.SyncOptions, udtSyncItem.Filter, udtRemoteFolder, udtLocalFolder)

                ...

            Catch ex As Exception
                   ....
            End Try

  •  05-08-2009, 1:50 PM Post no. 20830 in reply to 20818

    Re: FTP Synchronize terminate application

    Have you tried setting PassiveTransfer to true?  Is looks like the port is not open, and the server cannot make a connection to the data channel.
    André
    Software Developer
    Xceed Software Inc.
  •  05-09-2009, 4:39 PM Post no. 20842 in reply to 20830

    Re: FTP Synchronize terminate application

    I'll try that.

    But when I wrote terminate I mean "kills". Any clue why the FTP Synchronize kill the application even though it is wrapped in try,catch,finally blocks? I get an "error report" to send.

     Regards Andreas

  •  05-11-2009, 2:55 PM Post no. 20849 in reply to 20842

    Re: FTP Synchronize terminate application

    Exception thrown in events will not be caught if no try/catch block are found in event handlers.

    Moreover, the FTP control is multi-thread, thus exception thrown on other threads may not be caught by try/catch block either.

     


    André
    Software Developer
    Xceed Software Inc.
  •  05-14-2009, 2:34 AM Post no. 20925 in reply to 20849

    Re: FTP Synchronize terminate application

    Hello Andre,

    I've run with passive transfer and it took ~60h before it crashed. The Xceed trace log is added blow. How can I secure the call to Synchronizer.Synchronize? Even if there is error in connections we must be able to handle it, try later or inform the user. Any tip?

    In my first post I include a snippet of our call to Synchronize. We don't use SynchronizationEvents, and use simple name filters, and the following options.

                synchronizationOptions.AllowCreations = True
                synchronizationOptions.AllowDeletions = True
                synchronizationOptions.RecurseIntoSubFolders = blnSyncfoldersRecursive
                synchronizationOptions.CompareFileData = False
                synchronizationOptions.UseMetaData = True

     Regards Andreas

    < 250 CWD successful. "/Queue_Files" is current directory.
    > TYPE A
    < 200 Type set to A
    > PASV
    < 227 Entering Passive Mode (192,168,10,135,10,119)
    > LIST
    Data connection established with 192.168.10.135:2679 on 5/13/2009 @ 9:12:29 PM
    < 150 Connection accepted
    < 226 Transfer OK
    Connected to 192.168.10.135:21 on 5/13/2009 @ 9:12:30 PM
    < 220-FileZilla Server version 0.9.31 beta
    < 220-written by Tim Kosse (Tim.Kosse@gmx.de)
    < 220 Please visit http://sourceforge.net/projects/filezilla/
    > USER rtlaka
    < 331 Password required for rtlaka
    > PASS *****
    < 230 Logged on
    Connected to 192.168.10.135:21 on 5/13/2009 @ 9:12:30 PM
    < 220-FileZilla Server version 0.9.31 beta
    < 220-written by Tim Kosse (Tim.Kosse@gmx.de)
    < 220 Please visit http://sourceforge.net/projects/filezilla/
    > USER rtlaka
    < 331 Password required for rtlaka
    > PASS *****
    < 230 Logged on
    > PWD
    < 257 "/" is current directory.
    > CWD /Machines/FM/Machine_1/Settings
    < 250 CWD successful. "/Machines/FM/Machine_1/Settings" is current directory.
    > CWD /Machines/FM/Machine_1/Settings
    < 250 CWD successful. "/Machines/FM/Machine_1/Settings" is current directory.
    > CWD /Machines/FM/Machine_1/Settings
    < 250 CWD successful. "/Machines/FM/Machine_1/Settings" is current directory.
    > CWD /Machines/FM/Machine_1/Settings
    < 250 CWD successful. "/Machines/FM/Machine_1/Settings" is current directory.
    > TYPE A
    < 200 Type set to A
    > PASV
    < 227 Entering Passive Mode (192,168,10,135,10,120)
    > LIST
    Data connection established with 192.168.10.135:2680 on 5/13/2009 @ 9:12:30 PM
    < 150 Connection accepted
    < 226 Transfer OK
    Connected to 192.168.10.135:21 on 5/13/2009 @ 9:14:00 PM
    Disconnected from 192.168.10.135:21 on 5/13/2009 @ 9:14:30 PM
    Connected to 192.168.10.135:21 on 5/13/2009 @ 9:14:30 PM

     **** END ****

  •  05-14-2009, 3:49 PM Post no. 20958 in reply to 20925

    Re: FTP Synchronize terminate application

    Add a FileSystemEvents object to the Synchronize call, and handle the ItemException on it.  In the ItemException event handler, verify if you are still connected or not, and act accordingly.

    e.g.:

           ...
              AddHandler events.ItemException, AddressOf events_ItemException

              syncResult = Synchronizer.Synchronizeevents, Nothing, udtSynchronizationEvents, Nothing, udtRemoteFolder,udtSyncItem.SyncOptions, udtSyncItem.Filter, udtRemoteFolder, udtLocalFolder)

           ...


        Private Sub events_ItemException(ByVal sender As Object, ByVal e As ItemExceptionEventArgs)
          'If( connected )
            e.Action = ItemExceptionAction.Retry     
          'ElseIf( notconnected )
          '  e.Action = ItemExceptionAction.Abort
          'Endif
        End Sub

     


    André
    Software Developer
    Xceed Software Inc.
  •  05-27-2009, 3:09 AM Post no. 21208 in reply to 20958

    Re: FTP Synchronize terminate application

    Unfortunately it didn't help, this monday I experienced a new crash. I've added some extra exception handlers (see below) to see what actually happens, if possible.

    Application.ThreadException and currentDomain.UnhandledException

    It seems according to the FileZilla user interface that the server goes "down" at the same time it occures, as if it's an total network failure on my XP machine that runs the server. The application that runs the Xceed comopnent is running on a VirtualBox guest on my XP machine. The FileZilla user interface is able to reconnect and work as normal agian but as discussed in this thread the Xceed application terminates unexpected. 

    Regards Andreas


  •  05-27-2009, 5:56 PM Post no. 21233 in reply to 21208

    Re: FTP Synchronize terminate application

    I got this in my outer Exception, how can i take care of this to provide and safe application?

     regards Andreas

     MYExnHandler called with 5/27/2009 11:42:45 PM : The FTP command execution timed-out.
    Exception sourceXceed.Ftp
    Call stack :   at Xceed.Ftp.Engine.FtpCommand.OnCommandTimeout(Object state, Boolean timedOut)
       at System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context(Object state, Boolean timedOut)
       at System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context_t(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)

  •  06-03-2009, 5:23 PM Post no. 21376 in reply to 21233

    Re: FTP Synchronize terminate application

    Hi Andrea,

    since I don't know exactly what is going on with your connection, I can only give you a direction, not a solution.  You could monitor the ftp client state.  The possible states are Broken, Closed, Connecting, Executing, Fetching and Open.  So you could add to your code:

    AddHandler udtLocalFtpConnection.StateChanged, AddressOf OnStateChanged

    udtLocalFtpConnection.TraceWriter = new StreamWriter("D:\ftp.log", true )

    and then

    Private Sub OnStateChanged(ByVal sender As Object, ByVal e As StateChangeEventArgs)
        If e.CurrentState = ConnectionState.Broken Then
            '
            ' Do something useful to fix that broken connection?
            '
            Dim client As FtpClient
            client = CType(sender, FtpClient)
            client.TraceWriter.WriteLine("State has changed from:" + e.OriginalState.ToString() + " to " + e.CurrentState.ToString())
            ' client.Connect([...])
        End If
    End Sub
     

    Let me know if you can get somewhere with this. 
    Ghislain
    Technical Support and software developer
    Xceed Software Inc.
    Knowledge Base : http://xceed.com/kb/
    Update Center : http://xceed.com/updates/
    Documentation Center : http://xceed.com/doc/
    For everything else, there is Google
  •  06-08-2009, 8:50 AM Post no. 21444 in reply to 21376

    Re: FTP Synchronize terminate application

    Hello,

     I don't have that option to add for my FtpConnection  -> AddHandler udtLocalFtpConnection.StateChanged, AddressOf OnStateChange??

     Special feature?

    Regards Andreas

     

     

  •  06-11-2009, 2:01 AM Post no. 21529 in reply to 21376

    Re: FTP Synchronize terminate application

    Here's what i want to do in psuedo code. And I must be able to prevent or catch all exceptions that might occure. Preferable without to rig Application.ThreadException or such in my static main (the one I posted above 05-27-2009) that pops up dialogs about unhanlded expection. Is that possible? I run the synchronization 24/7with 2min intervalls, case I miss one it's no big deal aslong as i don't crash and can close up to prevent mem leakage.

    try

           createFtpConnection;

           setLocalFolder;

           setRemoteFtpFolder;

           doSynchronize;

    catch

          whatEverGoesWrong

     finally

          closeFtpConnection

    end

     

    regards Andreas

  •  06-25-2009, 2:44 PM Post no. 22048 in reply to 21444

    Re: FTP Synchronize terminate application

    Hi,

    you are right, StateChanged is an event of the FtpClient class, not the FtpConnection class.  I don't know what would be the impact and consequences (considering I don't much about your current app) but could you derive from FtpClient instead of FtpConnection?  Since I have not really tested the sample code above, I can't assure you that it would solve your problem.  Just suggesting.


    Ghislain
    Technical Support and software developer
    Xceed Software Inc.
    Knowledge Base : http://xceed.com/kb/
    Update Center : http://xceed.com/updates/
    Documentation Center : http://xceed.com/doc/
    For everything else, there is Google
  •  06-30-2009, 4:50 AM Post no. 22158 in reply to 22048

    Re: FTP Synchronize terminate application

    I can't see how FtpClient can be use with Synchronize/AbstractFolders, we used the same approach used in Xceed's FileSystem snippet examples "6.1.1  Synchronizing with FTP from Zip file". Do you got an snippet for an alternate approach?

     

    regards Andreas

  •  06-30-2009, 5:15 PM Post no. 22175 in reply to 22158

    Re: FTP Synchronize terminate application

    Hi,

    you are completely right, my initial suggestion to use the connection state is not compatible with the synchronization you are trying to do since these two functionalities are found in two different classes.  I will re-investigate this.  It doesn't seem to be anything quite trivial.


    Ghislain
    Technical Support and software developer
    Xceed Software Inc.
    Knowledge Base : http://xceed.com/kb/
    Update Center : http://xceed.com/updates/
    Documentation Center : http://xceed.com/doc/
    For everything else, there is Google
  •  08-10-2009, 1:32 AM Post no. 23251 in reply to 22175

    Re: FTP Synchronize terminate application

    Hello Ghislain,

     

    Any luck in your investigation? If not, any suggestion on what we can do?

    regards Andreas

Page 1 of 2 (17 items)   1 2 Next >
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.