Jump to content


Photo

FTP Library hangs when uploading a file


  • Please log in to reply
1 reply to this topic

#1 GeorgeCavallero

GeorgeCavallero
  • Members
  • 1 posts

Posted 27 June 2006 - 11:22 PM

I have downloaded the trial version of the FTP library for evaluation. We plan to purchase it for automated FTP uploading to a secure FTP site.

The problem I am having is when I get to the upload command the application hangs. It shows a zero length file on the server. I am using a MTA connection with VB.Net over SSL/TLS. I can login, connect and enter passive mode just fine. Everything works until the upload command is executed. I tried ascii mode and binary mode. Any ideas? Here is a list of my code. I copied it from you sample vb.net code. I have noticed occasionally the OnTransferProgress event fires, but nothing is written to the console log.

Thanks in advance for your help.
George Cavallero

Dim objGlobal As sfFTPLib.[Global]

objGlobal = New sfFTPLib.[Global]
objFTP = New sfFTPLib.FTPConnectionMTA

' Attach the event handler
AddHandler objFTP.OnConnect, AddressOf OnConnect
AddHandler objFTP.OnChangeDirectory, AddressOf OnChangeDirectory
AddHandler objFTP.OnTransferProgress, AddressOf OnTransferProgress
AddHandler objFTP.OnTransferInit, AddressOf OnTransferInit
AddHandler objFTP.OnUploadFile, AddressOf OnUploadFile
AddHandler objFTP.OnTransferStart, AddressOf OnTransferStart
AddHandler objFTP.OnTransferEnd, AddressOf OnTransferEnd
AddHandler objFTP.OnCommand, AddressOf OnCommand

objFTP.LogFile = "C:\smartftp.log"

objFTP.Host = "XXX.com"
objFTP.Port = 21
objFTP.Protocol = sfFTPLib.enumProtocol.ftpProtocolSSLExplicit
objFTP.Username = "XXX"
objFTP.Password = "XXX"
objFTP.LISTOption = True
objFTP.Passive = True
objFTP.DataProtection = sfFTPLib.enumDataProtection.ftpDataProtectionPrivate
objFTP.DataTransferMode = sfFTPLib.enumDataTransferMode.ftpDataTransferModeStream
objFTP.DataTransferType = sfFTPLib.enumDataTransferType.ftpDataTransferTypeASCII

' Proxy settings
objFTP.ProxyType = sfFTPLib.enumProxyType.ftpProxyTypeNone
objFTP.FTPProxyType = sfFTPLib.enumFTPProxyType.ftpFTPProxyTypeNone

If objFTP.Connect() = sfFTPLib.enumError.ftpErrorSuccess Then

Dim directoryName As String
Dim fileNameOnly As String
Dim filename As String

filename = "C:\CAD_Import\Files\HealthEMSFTPFiles\ImportFile_124963_file_call20060424010858.csv"
directoryName = Path.GetDirectoryName(filename)
Environment.CurrentDirectory = directoryName
fileNameOnly = Path.GetFileName(filename)

If objFTP.ChangeDirectory("/emsdata/agencydirs/vfd") = sfFTPLib.enumError.ftpErrorSuccess Then
objFTP.DataTransferType = sfFTPLib.enumDataTransferType.ftpDataTransferTypeImage
If objFTP.UploadFile(filename, fileNameOnly, 0, 0) = sfFTPLib.enumError.ftpErrorSuccess Then
System.Console.WriteLine("UploadFile() successful.")
System.Console.WriteLine("LastTransferBytes = {0} B", objFTP.LastTransferBytes)
System.Console.WriteLine("LastTransferTime = {0} s", objFTP.LastTransferTime)
System.Console.WriteLine("LastTransferSpeed = {0} B/s", objFTP.LastTransferSpeed)
Else
System.Console.WriteLine("UploadFile() failed. LastError = {0}", objFTP.LastError)
System.Console.WriteLine("LastReplyCode = {0}", objFTP.LastReplyCode)
System.Console.WriteLine("LastReply = {0}", objFTP.LastReply)
End If
End If
objFTP.Disconnect()
Else
If objFTP.LastError = sfFTPLib.enumError.ftpErrorLicense Then
System.Console.WriteLine("Please acquire a license from [url="http://www.smartftp.com")"]http://www.smartftp.com")[/url]
Else
System.Console.WriteLine("Connect() failed. LastError = {0}", objFTP.LastError)
End If
End If
objFTP = Nothing



Sub OnConnect()
System.Console.WriteLine("OnConnect()")
End Sub

Sub OnChangeDirectory(ByVal strDirectory As System.String)
System.Console.WriteLine("OnChangeDirectory(""{0}"")", strDirectory)
End Sub

Sub OnTransferProgress(ByVal nLo As System.Int32, ByVal nHi As System.Int32)
System.Console.WriteLine("OnTransferProgress(""{0}"")", objFTP.LastTransferBytes)
System.Console.WriteLine("Start Pos Low = " & nLo.ToString & "Start Pos Hi = " & nHi.ToString)
End Sub

Sub OnTransferInit()
System.Console.WriteLine("Transfer Initiated")
End Sub

Sub OnUploadFile(ByVal strLocalFile As System.String, ByVal strRemoteFile As System.String, ByVal nLo As System.Int32, ByVal nHi As System.Int32)
System.Console.WriteLine("Upload File Finished, Start Pos Low = " & nLo.ToString & "Start Pos Hi = " & nHi.ToString)
End Sub

Sub OnTransferStart()
System.Console.WriteLine("Transfer Started")
End Sub

Sub OnTransferEnd()
System.Console.WriteLine("Transfer Ended")
End Sub

Sub OnCommand(ByVal strCommand As System.String)
System.Console.WriteLine(strCommand & " Command implemented")
End Sub

#2 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 27 June 2006 - 11:27 PM

Hello ..

Please post the content of the log at "C:\smartftp.log" as well.

Thank you.
Regards,
-Mat




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users