By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

FtpWebRequest issue with GetRequestString

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.