Here is the portion from the FTP class Upload() method I have in regards to Rebex simplified so just to keep the relevant information:
oSftp = New Rebex.Net.Sftp
' Set event handlers
AddHandler oSftp.TransferProgress, AddressOf TransferProgressProxy
' If something is working
If lSftpWorking Then
cMessage = cWorking
Exit Try
End If
lSftpWorking = True
' Connect
oSftp.Options = oSftp.Options Or Rebex.Net.SftpOptions.UseLargeBuffers
oSftp.Timeout = 30000
loIAsyncResult = oSftp.BeginConnect(cHost, nPort, Nothing, Nothing, Nothing)
' While this is not completed
While Not loIAsyncResult.IsCompleted
Windows.Forms.Application.DoEvents()
System.Threading.Thread.Sleep(1)
End While
oSftp.EndConnect(loIAsyncResult)
' Login
oSftp.Login(cUsername, cPassword)
' Initialization
lSftpWorking = True
oSftp.BeginUpload(cLocalFile, cRemoteDirectory, _
Rebex.IO.TraversalMode.Recursive, Rebex.IO.TransferMethod.Copy, Rebex.IO.ActionOnExistingFiles.ThrowException, _
New AsyncCallback(AddressOf UploadCallback), Nothing)
' Until the upload is not completed
Do While lSftpWorking
' Wait a quarter second before proceding
System.Threading.Thread.Sleep(250)
lnUploaded = nSftpByteTransferred
lnActual = lnUploaded / nSize * 100
lnActualABS = Math.Abs(lnActual)
lnElapse = ((Date.Now.Ticks - lnStart) / 10000000)
lcMinute = oApp.SecondToFormat(lnElapse)
lnRemaining = nSize - lnUploaded
lnLast = lnActualABS
Loop
This is the UploadCallBack() method:
' Callback for upload finished
Private Function UploadCallback(ByVal toIAsyncResult As IAsyncResult) As Boolean
Try
oSftp.EndUpload(toIAsyncResult)
SafeInvoke(New TransferFinishedDelegate(AddressOf TransferFinished), New Object() {Nothing, True})
Catch loError As Exception
SafeInvoke(New TransferFinishedDelegate(AddressOf TransferFinished), New Object() {loError, True})
End Try
lSftpWorking = False
Return True
End Function
Those are relevant methods:
' Establishes the event for the transfer progress
Private Sub TransferProgressProxy(ByVal toSender As Object, ByVal toSftpTransferProgressEventArgs As Rebex.Net.SftpTransferProgressEventArgs)
SafeInvoke(New Rebex.Net.SftpTransferProgressEventHandler(AddressOf Me.TransferProgress), New Object() {toSender, toSftpTransferProgressEventArgs})
End Sub
' Event for the transfer progress
Private Sub TransferProgress(ByVal toSender As Object, ByVal toSftpTransferProgressEventArgs As Rebex.Net.SftpTransferProgressEventArgs)
' If we have some new data
If toSftpTransferProgressEventArgs.BytesSinceLastEvent > 0 Then
nSftpByteTransferred = nSftpByteTransferred + toSftpTransferProgressEventArgs.BytesSinceLastEvent
End If
End Sub
This methods is only called at the end on a desktop application. However, from a Console or Windows Service application, it is being called right away after it created the file on the FTP server with 0 byte. So, as this method is called right away, the process never finishes as it is not normal this method is called before the file is being completely uploaded.
I cannot post the log online but you will receive it by email.