Hello
I am in the process of making a small app that will be used by the slightly
more, er, IT challenged customers we have to send us their databases via
FTP.
Going ok, but when I come to writing the data stream it is terminating with
"unable to write data to the transport connection tcpclient"
Adding a quick messagebox on the exception, I am getting:
"An established connection was aborted by the software in your host
machine".
code sample:
'Begin upload of data
Dim TheStream As Stream = Conn.GetStream
Dim StreamStatus As Boolean = TheStream.CanWrite
BytesRead = FStream.Read(bData, 0, 1024)
TheStream.Write(bData, 0, 1024)
TotalBytes = 1024
While BytesRead > 0
Try
BytesRead = FStream.Read(bData, 0, 1024)
TheStream.Write(bData, 0, BytesRead)
TotalBytes = TotalBytes + 1024
RaiseEvent SendProgress(TotalBytes)
Catch ex As Exception
MsgBox("Error sending data:" & vbCrLf & vbCrLf &
ex.GetBaseException.Message & vbCrLf & vbCrLf & "Stack Trace:" &
vbCrLf & ex.GetBaseException.StackTrace, MsgBoxStyle.Exclamation, "Error
sending data")
Exit While
End Try
End While
It is failing on the looping bit of sending- the first send passes ok. If I
connect in to the FTP server manually via the windows command line ftp
client, I can see my destination file with a size of 0 bytes.
I am using pasv mode as I am behind a NAT Router and the active mode meant
that I would be sending the PORT command with my local IP address
(192.168.x.x).
We also have an odd dual router setup here - a nat router with 2 adsl modems
running off it in load balancing. Although I am forcing all port 21 traffic
down one channel, the second connection for the data stream often goes down
the other meaning it the data part doesn't even connect. I dont mind that as
the customers won't have anything similar, but I wonder if it is part of the
problem I am having? I guess once the connection is established my sending
of data to the stream won't swap channel willy-nilly?
James.