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 ServerProtocolV iolation exception when
calling GetRequestStrea m 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 WebRequestMetho ds.Ftp.UploadFi le, 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
ServerProtocolV iolation exception, but that is my next step:
Exception of Type "System.Net.Web Exception"
The underlying connection was closed: The server committed a protocol
violation.
ftp://205.156.51.29/T_Dsi_101_C_KWBC_20051016072548.txt
Status: ServerProtocolV iolation
StackTrace:
at System.Net.FtpW ebRequest.SyncR equestCallback( Object obj)
at System.Net.FtpW ebRequest.Reque stCallback(Obje ct obj)
at System.Net.Comm andStream.Abort (Exception e)
at System.Net.FtpW ebRequest.Finis hRequestStage(R equestStage stage)
at System.Net.FtpW ebRequest.GetRe questStream()
at DsiGlobal.Net.F tpClient.Upload File(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: ServerProtocolV iolation.
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::Cre ate(ftp://205.156.51.29/T_Dsi_101_C_KWBC_20051015201816.txt)
System.Net Information: 0 : [0972]
FtpWebRequest#1 7653682::.ctor(ftp://205.156.51.29/T_Dsi_101_C_KWBC_20051015201816.txt)
System.Net Verbose: 0 : [0972] Exiting WebRequest::Cre ate() ->
FtpWebRequest#1 7653682
System.Net Verbose: 0 : [0972] FtpWebRequest#1 7653682::GetReq uestStream()
System.Net Information: 0 : [0972]
FtpWebRequest#1 7653682::GetReq uestStream(Meth od=STOR.)
System.Net Information: 0 : [0972] Associating FtpWebRequest#1 7653682 with
FtpControlStrea m#42194754
System.Net Information: 0 : [0972] FtpWebRequest#1 7653682::(Relea sing FTP
connection#4219 4754.)
System.Net Error: 0 : [0972] Exception in the
FtpWebRequest#1 7653682::GetReq uestStream - The underlying connection was
closed: The server committed a protocol violation.
System.Net Error: 0 : [0972] at
System.Net.FtpW ebRequest.SyncR equestCallback( Object obj)
at System.Net.FtpW ebRequest.Reque stCallback(Obje ct obj)
at System.Net.Comm andStream.Abort (Exception e)
at System.Net.FtpW ebRequest.Finis hRequestStage(R equestStage stage)
at System.Net.FtpW ebRequest.GetRe questStream()
System.Net Verbose: 0 : [0972] Exiting
FtpWebRequest#1 7653682::GetReq uestStream()
That's about all I can provide. Any ideas?
--
TIA,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.