Error reading the HTTPListenerRequest InputStream

K

Kunal

Hi Friends,

When I try to read the incoming client request data using the
HttpListenerRequest.InputStream property, I'm getting the following
exception (not everytime) -

System.Net.HttpListenerException: The I/O operation has been aborted
because of either a thread exit or an application request

Server stack trace:
at System.Net.HttpRequestStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
at HttpListenerLibrary.HttpListenerWrapper.ProcessRequest() in
C:\AcsSim\HttpListenerLibrary\HttpListenerLibrary.cs:line 901
at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle
md, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage
msg, Int32 methodPtr, Boolean fExecuteInContext)

The server doesn't crash after this but stops receiving any further
requests. What could be the problem that makes it do so ?

Do I have any way of finding out what kind of request is this ?
Can I programmatically insert a breakpoint in the code when this
exception comes ?
How can I ensure that if this exception happens my HttpListener still
continues to receive packets ?

Thanks for going through my problem.

Regards,
Kunal

P.S. The code that I use to read the inputstream is as follows -

if (!request.HasEntityBody)
{
Console.WriteLine("No client data was sent with the request.");
return;
}
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = request.ContentEncoding;
System.IO.StreamReader reader = new System.IO.StreamReader(body,
encoding);


string s = reader.ReadToEnd();
Console.WriteLine(s);
body.Close();
reader.Close();
 
K

Kunal

Well yes, I'm already using a try-catch block and I do catch the
HttpListenerException
but after the exception is caught, the HttpListener stops working i.e.
it does not receive
packets from the stack anymore (using getContext) though there are
packets coming
in on the wire. Also, the application in itself does not crash or
something.
 
K

Kunal

Anyone faced any such problem before ???


Well yes, I'm already using a try-catch block and I do catch the
HttpListenerException
but after the exception is caught, the HttpListener stops working i.e.
it does not receive
packets from the stack anymore (using getContext) though there are
packets coming
in on the wire. Also, the application in itself does not crash or
something.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top