Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set http request queue length when self hosting webapi?

Running ASP.NET WebApi I would like to set the HTTP request queue length.

I found some blog indicating this should be possible on OwinHttpListener and also in the msdn documentation .

So I used this approach to get the OwinHttpListner

public void Configuration(IAppBuilder appBuilder)
{
    HttpConfiguration config = new HttpConfiguration();
    var owinListenerName = "Microsoft.Owin.Host.HttpListener.OwinHttpListener";
    var owinListener = (OwinHttpListener)appBuilder.Properties[owinListenerName];
    // more code...
}

But the method SetRequestQueueLimit was not there. Using ILSpy also showed that there is no such internal method on that class.

I'm using nuget package Microsoft.Owin.Host.HttpListener 2.0.2

What am I missing here?

like image 773
Thomas Avatar asked Sep 05 '26 07:09

Thomas


1 Answers

I found out that there was a later version available so I did an update of all my nuget packages which updated the package Microsoft.Owin.Host.HttpListener to version 3.0.1 and then the method was present.

Using netsh like:

netsh http show servicestate

verifies that the value of the request queue was actually updated.

I think it was because I originally installed the package Microsoft.AspNet.WebApi.OwinSelfHost which had a dependency on Microsoft.Owin.Host.HttpListener 2.0.2 or higher which was the reason I got the old version.

Hopefully someone else will be helped by this...

like image 84
Thomas Avatar answered Sep 06 '26 19:09

Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!