Re: Unable to Connect to a Site using FTPSwithData - WeOnlyDo Discussion board

Re: Unable to Connect to a Site using FTPSwithData (General questions)

by ogedei, Wednesday, September 05, 2007, 23:26 (6288 days ago) @ ogedei

Ok your sample works but my code does not.

I am not using the event driven model
[code]
Try
oFTP.Blocking = True
oFTP.Hostname = FTP.URL
oFTP.LicenseKey = FTPLicenseKey
oFTP.LocalPath = procedure.LocalDir
oFTP.Login = FTP.UserName
oFTP.Passive = FTP.Passive
oFTP.Password = FTP.Password
oFTP.Protocol = CType(FTP.Protocol, WeOnlyDo.Client.Protocols)
oFTP.Port = FTP.Port
oFTP.RemotePath = procedure.RemoteDir
oFTP.Timeout = FTP.TimeOut
If oFTP.State = WeOnlyDo.Client.States.Disconnected Then
oFTP.Connect()
End If

If oFTP.State = WeOnlyDo.Client.States.Connected Then
oFTP.TransferMode = WeOnlyDo.Client.TransferModes.Binary
End If
Catch ex As Exception
Dim errString As String
errString = Site: & vbTab & FTP.FTPName & vbCrLf & Error Msg: & vbTab & oFTP.LastError.Message 'oFTP.ErrorText(oFTP.LastError)
EventLog.WriteEntry( FTP.New , errString, System.Diagnostics.EventLogEntryType.Error)
Dim oFileRoomService As New FileRoomService
FileRoomService.SendMail( Error Connecting to a FTP Server. , errString)
Throw ex
End Try

Try
oFTP.ListDir() 'Error is occuring here
Catch ex As Exception
oFTP.Disconnect()
Dim errString As String
errString = Site: & vbTab & FTP.FTPName & vbCrLf & Error Msg: & vbTab & oFTP.LastError.Message 'oFTP.ErrorText(oFTP.LastError)
EventLog.WriteEntry( FTP.New , errString, System.Diagnostics.EventLogEntryType.Error)
Dim oFileRoomService As New FileRoomService
FileRoomService.SendMail( Error Connecting to a FTP Server. , errString)
Throw ex
End Try
[/code]

I am using blocking so everything should complete before the code moves on. when I get to the ListDir line I get a Invalid PORT address on one site and a Can't open data connection. from a different site.

Please assist


I also received this from the debugger. It looks like it might be coming from inside of your component but I do not have a line number or a location in my code to trace it back to. I am going to keep looking.

System.NullReferenceException was unhandled
Message= Object reference not set to an instance of an object.
Source= WeOnlyDo.Client.FTP
StackTrace:
at ..( , Exception )
at ..(IAsyncResult )
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.CompleteCallback(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)


Complete thread: