Home Forums .NET libraries Xceed SFTP/FTP for .NET FTP Synchronize terminate application

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21192 |

    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

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 10646 views)

    User (Old forums)
    Member
    Post count: 23064

    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.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 1043 views)

    User (Old forums)
    Member
    Post count: 23064

    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

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 4523 views)

    User (Old forums)
    Member
    Post count: 23064

    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.

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 4080 views)

    User (Old forums)
    Member
    Post count: 23064

    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 ****

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 970 views)

    User (Old forums)
    Member
    Post count: 23064

    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

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 4014 views)

    User (Old forums)
    Member
    Post count: 23064

    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

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 1040 views)

    User (Old forums)
    Member
    Post count: 23064

    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)

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 4266 views)

    User (Old forums)
    Member
    Post count: 23064

    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. 

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Ghislain (had 5817 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello,

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

     Special feature?

    Regards Andreas

     

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 3942 views)

    User (Old forums)
    Member
    Post count: 23064

    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

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 3933 views)

    User (Old forums)
    Member
    Post count: 23064

    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.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Ghislain (had 3002 views)

    User (Old forums)
    Member
    Post count: 23064

    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

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 1085 views)

    User (Old forums)
    Member
    Post count: 23064

    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.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Ghislain (had 3077 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello Ghislain,

     

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

    regards Andreas

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Andreas (had 1723 views)

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.