FTP w CF 2.0  
Author Message
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

Hi all,

I am getting an odd error during an FTP. It happens completely randomly. I can sometimes ftp 50 files with no error, and other times 2 errors in a row with the same files. This machine can FTP via CF 1.1 without error as well as with any other FTP method I have tried. Like I said it only happens with the 2.0 and I am at a loss. Any ideas Here is the error;

System.Net.WebException: The remote server returned an error: (501) Syntax error in parameters or arguments.

at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)

at System.Net.FtpWebRequest.RequestCallback(Object obj)

at System.Net.CommandStream.Abort(Exception e)

at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)

at System.Net.FtpWebRequest.GetRequestStream()



.NET Development22  
 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

Sorry, forgot to mention the FTP is to an AS400
 
 
Mariya Atanasova - MSFT





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

AS400 was indeed a key point. You can find details here

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=150746&SiteID=1

Mariya


 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

Thanks for the response, but I do not see that this can be the issue. My code works 95% of the time with no change. My code is below;

Dim requestStream As IO.Stream = Nothing
Dim fileStream As IO.FileStream = Nothing
Dim FTPreq As FtpWebRequest = Nothing
Dim uploadResponse As FtpWebResponse = Nothing

")

FTPreq.Method = WebRequestMethods.Ftp.UploadFile
FTPreq.Proxy = Nothing

requestStream = FTPreq.GetRequestStream
fileStream = IO.File.Open("C:\FiletoUpload.txt", IO.FileMode.Open)

Dim buffer(1024) As Byte
Dim bytesRead As Integer
While True
bytesRead = fileStream.Read(buffer, 0, buffer.Length)
If bytesRead = 0 Then
Exit While
End If
requestStream.Write(buffer, 0, bytesRead)
End While
requestStream.Close()
uploadResponse = FTPreq.GetResponse()

fileStream.Close()
fileStream = Nothing


 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

Do you disagree
 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

This is really killin me here. Anyone else seen this or overcome it
 
 
Mariya Atanasova - MSFT





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

It is not that your code is wrong (you can test against another Ftp server and it will work) what you're running into is an existing limitation of the FtpWebRequest. We issue "CWD /" and AS200 doesn't support it. Currently we do not have a workaround for this.We have this in the database, and it will be fixed in a future release.

Mariya


 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

I understand what you are saying, but the posted code works most of the time against an AS400. If I tried to FTP 10 files to the same AS400 using the code I posted, 9 of the 10 files will make it. My question is , based on your information, the code should not work at all with an AS400, but it does. How is this possible
 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

Mariya, Is there any information on why it works sometimes and sometimes not I really would like to put this thing to bed soon.

regards,

Bill


 
 
Mariya Atanasova - MSFT





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

I appologize for the delay. We had some pretty strict deadlines to meet and I hadn't had a chance to look at your issue.

It also seems I misunderstood your issue. So lets take a step back. Can you repro it consistently: i.e. it happens everytime for a particualr file or at a particular place or is it completely random In both cases I'll need to a SystemNet.log trace and a network sniff (you can use either Netmon or Ethereal).

In case you need instructions on how to get a trace look here:

http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx
http://blogs.msdn.com/dgorti/archive/2005/10/29/486887.aspx

You can post the traces or send them to me in an email.

Mariya


 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

Mariya,

Let me first admit a mistake I made with the subject title of this post. I marked it as ftp with CF 2.0. Just to clarify this is not the compactframework I am working with. Just .NET Framework 2.0

Thanks for your response, and to answer your question, this issue is 100% random. Several times a day I need to send a group of files. These files are the same structure and are always about 5 kb in size. These files are sent via FTP to a local AS400 using the code I posted above. For an example say there are 10 files to be sent. Sometims all transfer with no issue. Sometimes only 8 make it and the 9th errors out with the above error. If I just retry the send again, the same files go with no problem. At times, I can go several days with no issue, and others I will get the error 2 times in a row. Random times, random days , and I can not repro the issue at will. I will get a trace, and when I get the error , I will post it.

Regards


 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

I think I have foud the issue. It appears that after sending one file, any files after may or may not fail. I connect , do the FTP, and exit. For the next file I create a new connection. This is where I think the issue is. It does not appear that the AS400 closes the connection each time, before I begin a new transfer. How do I send a finish or end command The ExitMessage property of the FTPWebResponse object is always ""(empty)
 
 
Woyler





PostPosted: .NET Framework Networking and Communication, FTP w CF 2.0 Top

The solution is to set the KeepAlive property of the FTPWebRequest object to false. It send a QUIT command to the server after the transfer is complete.