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();

Re: Error reading the HTTPListenerRequest InputStream by Ashot

Ashot
Wed Jan 10 18:20:40 CST 2007

try{} catch{} ?

"Kunal" <koolkunal@gmail.com> wrote in message
news:1168469484.284071.49210@o58g2000hsb.googlegroups.com...

> 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 ?



Re: Error reading the HTTPListenerRequest InputStream by Kunal

Kunal
Thu Jan 11 08:52:26 CST 2007

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.


On Jan 10, 6:20 pm, "Ashot Geodakov" <a_geoda...@hotmail.com> wrote:
> try{} catch{} ?
>
> "Kunal" <koolku...@gmail.com> wrote in messagenews:1168469484.284071.49210@o58g2000hsb.googlegroups.com...
>
>
>
> > 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 ?- Hide quoted text -- Show quoted text -


Re: Error reading the HTTPListenerRequest InputStream by Kunal

Kunal
Thu Jan 11 11:14:32 CST 2007

Anyone faced any such problem before ???


On Jan 11, 8:52 am, "Kunal" <koolku...@gmail.com> wrote:
> 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.
>
> On Jan 10, 6:20 pm, "Ashot Geodakov" <a_geoda...@hotmail.com> wrote:
>
>
>
> > try{} catch{} ?
>
> > "Kunal" <koolku...@gmail.com> wrote in messagenews:1168469484.284071.49210@o58g2000hsb.googlegroups.com...
>
> > > 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 ?- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -