473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

FtpWebRequest issue with GetRequestString

Hi all,

I am working on a service that uploads METAR weather information to the
National Weather Service FTP site. The service I'm authoring is hosted on a
Windows 200 server, and the NWS FTP host is on a Unix server. I'm using the
FtpWebRequest and FtpWebResponse classes to do the file uploading. I have
tested it without any errors at all uploading to an IIS FTP server hosted on
our network Most of the time it uploads without error to the NWS server.

However, it intermittently throws a ServerProtocolViolation exception when
calling GetRequestStream on the NWS server. My research has indicated to me
that, first, I am doing everything necessary on the client side, including
setting the Request.Method to WebRequestMethods.Ftp.UploadFile, setting the
transfer type to ASCII, using an ASCII-encoded byte stream, and am using
PASV mode. It connects and authenticates with the server just fine. In fact,
it does everything else without incident, and as I mentioned before, usually
works without error.

I Googled the issue for a couple of hours, and found some references to a
possible issue with an incorrect Response Header. I was not able to confirm
this, however, and I'm not sure that this is the issue.

I also noticed that the HttpWebRequest has apparently had some issues with
Response headers that don't comply with the latest RFC, and a configuration
setting that disables exceptions for this particular issue when needed.
However, I couldn't find a similar configuration setting, or a property of
the FtpWebRequest that corresponded. Still, I'm not sure that this is the
issue, as I can't dig deep enough into the class structure to confirm this.

The following is the EventLog entry that my app writes when the exception
occurs. I haven't yet implemented a method for dissecting the
ServerProtocolViolation exception, but that is my next step:

Exception of Type "System.Net.WebException"

The underlying connection was closed: The server committed a protocol
violation.
ftp://205.156.51.29/T_Dsi_101_C_KWBC_20051016072548.txt
Status: ServerProtocolViolation
StackTrace:
at System.Net.FtpWebRequest.SyncRequestCallback(Objec t obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(Reques tStage stage)
at System.Net.FtpWebRequest.GetRequestStream()
at DsiGlobal.Net.FtpClient.UploadFile(Byte[] fileContents, String name,
String& ResponseInfo, TimeSpan& ts)

The underlying connection was closed: The server committed a protocol
violation.
ftp://205.156.51.29/T_Dsi_101_C_KWBC_20051016072548.txt
Status: ServerProtocolViolation.

I turned on Network Tracing so that I could see exactly where the exception
occurs, and perhaps find out why, but I am not able to discern this from the
trace. The following is a fragment of the Trace Log:

System.Net Verbose: 0 : [0972]
WebRequest::Create(ftp://205.156.51.29/T_Dsi_101_C_KWBC_20051015201816.txt)
System.Net Information: 0 : [0972]
FtpWebRequest#17653682::.ctor(ftp://205.156.51.29/T_Dsi_101_C_KWBC_20051015201816.txt)
System.Net Verbose: 0 : [0972] Exiting WebRequest::Create() ->
FtpWebRequest#17653682
System.Net Verbose: 0 : [0972] FtpWebRequest#17653682::GetRequestStream()
System.Net Information: 0 : [0972]
FtpWebRequest#17653682::GetRequestStream(Method=ST OR.)
System.Net Information: 0 : [0972] Associating FtpWebRequest#17653682 with
FtpControlStream#42194754
System.Net Information: 0 : [0972] FtpWebRequest#17653682::(Releasing FTP
connection#42194754.)
System.Net Error: 0 : [0972] Exception in the
FtpWebRequest#17653682::GetRequestStream - The underlying connection was
closed: The server committed a protocol violation.
System.Net Error: 0 : [0972] at
System.Net.FtpWebRequest.SyncRequestCallback(Objec t obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(Reques tStage stage)
at System.Net.FtpWebRequest.GetRequestStream()
System.Net Verbose: 0 : [0972] Exiting
FtpWebRequest#17653682::GetRequestStream()

That's about all I can provide. Any ideas?

--
TIA,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.


Nov 17 '05 #1
0 3518

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: jose.lopes.cruz | last post by:
I need to access a FTP Server. I'm using FTPWebRequest as described in visual studio 2005 documentation. Everything works fine except the following: 1) I dont know how to change de current...
3
by: Sputnik | last post by:
If I create an MFC application in Visual Studio 6 using the following code: CInternetSession inet_session; CFtpConnection *ftp_connection; ftp_connection = inet_session.GetFtpConnection(...
3
by: Kevien Lee | last post by:
hi everyone I have a quick question when i use the FtpWebRequest. What I need to do is that: Connect a FTP server,check whether there is a folder if not,create it, then changed the path to...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
6
by: William LaMartin | last post by:
Could someone show me how to use the FtpWebRequest and change to a different directory? Changing directories is not listed as one of the methods, but I believe it can be done--just can't figure...
0
by: RodeoClownCC | last post by:
Hello, I'm trying to create a simple FTP client using VB .NET's FTPWebRequest methods, and have unfortunately run into a snag. The problem I'm having is the client connects to an FTP server,...
2
by: deciacco | last post by:
is there way to use the ftpwebrequest class to send the list -r command? thanks
9
by: Waldy | last post by:
Hi there, I have written a service in VS2005 that downloads files from an FTP site processes them and then deletes the files if successfully processed. It all works fine when run in our test lab...
6
by: Patrick.Simons | last post by:
I try to connect a FTPWebRequest through Proxy and VPN to a remote FTP- server. Sometimes it works sometimes not. When my VB.Net-App (2005) returns the error on the GetResponse-Method, I'll try to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.