Hi,
I am connecting to a GlobalScape FTP server using port 990. The conenction is fine, but as soon as I try to list the folder contents the code stops and eventually times out. I have tried various settings for the Timeout property and none appear to work. I can connect to the server using FileZilla with no problems, but we have found before that DART's SFTP components do not work against that server.
It also fails if I set PassiveTransfer to True. However in that situation I get the following error:
Xceed.Ftp.FtpIOException was unhandled
Message="An I/O error occurred while accepting the FTP server's data connection."
Source="Xceed.Ftp"
StackTrace:
at Xceed.Ftp.Engine.FtpCommandSequence.EndExecute(IAsyncResult asyncResult)
at Xceed.Ftp.FtpClient.DoExecuteCommand(FtpCommandChannel commandChannel, BaseFtpCommand command)
at Xceed.Ftp.FtpClient.DoGetFolderContents(FtpCommandChannel commandChannel, ListFtpCommand listCommand)
at Xceed.Ftp.FtpClient.GetFolderContents(String remoteFileMask)
at HSTFTPServiceTester.Form1.Button2_Click(Object sender, EventArgs e) in E:\Framework\Framework\BusinessObjects\HSTResults\HSTResultGateway\HSTFTPServiceTester\Form1.vb:line 108
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at HSTFTPServiceTester.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Net.Sockets.SocketException
ErrorCode=10061
Message="No connection could be made because the target machine actively refused it ServerIP:3454"
NativeErrorCode=10061
Source="System"
StackTrace:
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at Xceed.Ftp.Engine.PassiveFtpDataChannel.ConnectCompleted(IAsyncResult asyncResult)
InnerException:
Can you help?
Heres my code, slightly edited for security:
Private WithEvents FTPClient As Xceed.Ftp.AsyncFtpClient
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Xceed.Ftp.Licenser.LicenseKey =
"Valid licence key"
FTPClient =
New Xceed.Ftp.AsyncFtpClient
FTPClient.TraceWriter =
New IO.StreamWriter("E:\XCeedFTP.log", True)
' http://xceed.com/CS/forums/thread/20997.aspx
FTPClient.UseRemoteAddress =
True
FTPClient.PassiveTransfer =
False
FTPClient.Timeout = 90
Dim VerificationFlags As Xceed.Ftp.VerificationFlags
VerificationFlags = Xceed.Ftp.VerificationFlags.IgnoreInvalidBasicConstraints
FTPClient.Connect("ServerIP", "990", Xceed.Ftp.AuthenticationMethod.Tls, _
VerificationFlags,
Nothing)
FTPClient.Login(
"UserName", "Password")
Dim LocalFilename As String = "E:\Downloads\XceedDownload.txt"
If IO.File.Exists(LocalFilename) Then IO.File.Delete(LocalFilename)
'Get a list of a folders contents
FTPClient.ChangeCurrentFolder(
"/From_Pro")
Dim x As Xceed.Ftp.FtpItemInfoList = FTPClient.GetFolderContents("*.*")
'Get a file
FTPClient.ChangeCurrentFolder(
"/")
FTPClient.ReceiveFile(
"/From_Pro/2009.09.29.dnl", LocalFilename)
End Sub
Private Sub FTPClient_CertificateReceived(ByVal sender As Object, ByVal e As Xceed.Ftp.CertificateReceivedEventArgs) Handles FTPClient.CertificateReceived
If e.ServerCertificate.Thumbprint = "Valid thumb print here" Then
e.Action = Xceed.Ftp.VerificationAction.Accept
End If
End Sub
The Trace file output is:
Connected to ServerIP:990 on 01/10/2009 @ 10:02:21
< 220 Prometric Secure FTP Server
> PBSZ 0
< 200 PBSZ Command OK. Protection buffer size set to 0.
> PROT P
< 200 PROT Command OK. Using Private data connection
> USER UserName
< 331 Password required for UserName.
> PASS *****
< 230-WARNING: You are entering a restricted system. All data and information herein may be considered as confidential and is proprietary to XX.
< 230-Please ensure you have the proper authorization before proceeding. Activity on this system is subject to monitoring for unauthorized access.
< 230-Where such monitoring reveals unauthorized access or use, XX shall invoke all applicable rights to investigate and prosecute violators through subsequent civil and/or
< 230-criminal proceedings.
< 230-Welcome to the XX Private FTP Server.
< 230 If you experience any difficulties with this service, please contact your Program Manager at XX.
> CWD /From_Pro
< 250 Folder changed to "/From_Pro".
> TYPE A
< 200 Type set to A.
> PORT 192,168,254,131,6,189
< 200 Command okay.
> LIST *.*