Home All Groups Group Topic Archive Search About

ftpwebreques async upload, active transfer problem.

Author
10 Apr 2006 2:46 AM
lushdog
Hi, i'm having an inssure implementing and ftpwebrequest upload, using
an active transfer problem.  I'm trying to catch the "425 Can't open
data connection" error returned if an ftp client in active mode tries
to connect to an ftp server, and one or the other or both are not
configured properly.

Here is the code in question:

.........
Dim result As IAsyncResult
                    result = request.BeginGetRequestStream(New
AsyncCallback(AddressOf EndGetStreamCallback), state)
                   waitObject.WaitOne()
...................

Private Sub EndGetStreamCallback(ByVal ar As IAsyncResult)
        'User created class to handle async file transfer
        Dim state As FtpState = CType(ar.AsyncState, FtpState)
        'Stream to send to ftp server
        Dim requestStream As Stream = Nothing

        Try
            ' attach the requestStream to the FTPWEBREQUEST
            requestStream = state.Request.EndGetRequestStream(ar)
        Catch ex As System.Net.WebException
            ' handle ....................
      ........................

A breakpoint has been place at "Dim state As FtpState =
CType(ar.AsyncState, FtpState)", the first line in
EndGetStreamCallback.  When the ftpwebrequest is set to use passive
mode, the code breaks at the right line.  When the ftpwebrequest is set
to use active mode, and the conditions are as stated above for the
client and server,  the code never gets to the break point and hangs
forever at "waitObject.WaitOne()".  If i set the ftpwebrequest to use
syncronous transfer and the condistions are as stated above for the
client and server, the request returns a timeout.

So if my request never even gets to the EndGetStreamCallback code, how
can i check for connection errors/timeouts?

TIA, lushdogg

AddThis Social Bookmark Button