Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2005

Tip: Looking for answers? Try searching our database.

FtpWebRequest ServerProtocolViolation calling GetRequestStream method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin Spencer - 16 Oct 2005 14:03 GMT
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(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()
  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=STOR.)
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(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()
System.Net Verbose: 0 : [0972] Exiting
FtpWebRequest#17653682::GetRequestStream()

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

Signature

TIA,

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

Feroze [msft] - 27 Oct 2005 22:51 GMT
Can you install a network sniffer like ethereal or netmon and see what is
going on over the wire?

Signature

feroze

-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.

See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------

> Hi all,
>
[quoted text clipped - 81 lines]
>
> That's about all I can provide. Any ideas?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.