25

I have this error in ASP.NET application , NET 4.7.1.

The request queue limit of the session is exceeded.

Full:

System.Web.HttpException (0x80004005): The request queue limit of the session is exceeded.
at System.Web.SessionState.SessionStateModule.QueueRef()
at System.Web.SessionState.SessionStateModule.PollLockedSession()
at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)

any suggestions ?

Kiquenet
  • 14,494
  • 35
  • 148
  • 243

3 Answers3

33

The default behavior has changed in .NET 4.7. Retargeting guide suggests:

To restore the old behavior, you can add the following setting to your web.config file to opt-out of the new behavior.

<appSettings>
  <add key="aspnet:RequestQueueLimitPerSession" value="2147483647"/>
</appSettings>

Clarification of changed behavior:

In the .NET Framework 4.6.2 and earlier, ASP.NET executes requests with the same Sessionid sequentially and ASP.NET always issues the Sessionid through cookies by default. If a page takes a long time to respond, it will significantly degrade server performance just by pressing F5 on the browser. In the fix, we added a counter to track the queued requests and terminate the requests when they exceed a specified limit. The default value is 50. If the limit is reached, a warning will be logged in the event log, and an HTTP 500 response may be recorded in the IIS log.

Also addressed here: https://knowledgebase.progress.com/articles/Article/The-request-queue-limit-of-the-session-is-exceeded-in-sitefinity-11-2

Mart Wienk
  • 361
  • 3
  • 5
  • 2
    Which is the cause? Not solution without restore the old behavior ? Not error in 4.5, error in 4.7.1... bug in 4.7.1? Fix is to restore the old behavior. – Kiquenet Jan 27 '20 at 22:13
  • 2
    Yeah, it's probably a bug in 4.7.1, as it's caused by recent changes in the 4.7 version. I don't know the specific cause, but the Microsoft Documentation also refers to this retargeting type of solution. All suggested changes regarding the update from 4.5.2 to 4.7.1 are documented here: https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/retargeting/4.5.2-4.7.1. – Mart Wienk Jan 27 '20 at 22:22
  • 1
    why the page takes a long time to respond? https://world.episerver.com/blogs/mahdi-shahbazi/dates/2018/10/the-request-queue-limit-of-the-session-is-exceeded--system-web-httpexception-at-system-web-sessionstate-sessionstatemodule-queueref/ Too: `` – Kiquenet Jan 28 '20 at 20:42
  • I got some confusion here, if my application is running on .net framework 4.7.1 and getting the error: The request queue limit of the session is exceeded, Then the value of aspnet:RequestQueueLimitPerSession should be 25 or 2147483647 ? – ArjunArora Sep 22 '20 at 15:06
  • This error can happen also in .Net 4.6.2, any idea how to fix it? – Igor Sep 07 '22 at 09:27
  • 1
    This isn't a bug but a feature. It helps prevent overloading a slow endpoint. It sets a limit of 50 queued requests per user session per resource. Remember that requests that differ only by querystring parameters are considered the same resource. If you have an old app with links like image.aspx?id=1234 and you call that many times on a page, you could run into this. MVC endpoints tend to avoid this because the URI is unique per resource (/image/1234). – Neil Laslett Jun 08 '23 at 14:08
3

I was getting the same error in my MVC application (.NET version 4.7.2) on days with unusually high activity. I fixed it by adding the necessary table indexes in the application's database. In my case, the solution was not to adjust the "aspnet:RequestQueueLimitPerSession" setting but to address the underlying problem regarding database performance that caused the session requests to exceed the default limit.

kyletme
  • 441
  • 4
  • 17
  • 1
    adding the necessary table indexes ? do you use any tool for get recommended indexes ? – Kiquenet Nov 15 '21 at 20:50
  • 2
    I used the Activity Monitor tool available in SQL Server Management Studio to identify "Recent Expensive Queries". I ordered the results by "Executions/min" and "CPU (ms/sec)" to find the stored procedure causing the problem. Next, I executed the stored procedure in SQL Server Management Studio with the option "Include Actual Execution Plan" and SQL Server identified the missing index for me. I hope this helps. Let me know if you need more information. – kyletme Nov 20 '21 at 01:25
2

Some time this error is generated by to many redirects on server side, after investigation I detect that in the fact user is redirected to same action by ActionsFilter after I fixed this error has not occurred, I think if you investigate IIS logs you are more likely to find the same problem.

PS. For this case setting RequestQueueLimitPerSession will not solve the problem.

TO REPRODUCE: Open IE 11 open the specified path and press F5 for 60 sec. It will generate a lot of requests to this path and if we'll take a look to iis then we will find some requests with win-32 status = 64 enter image description here

Quite analyzing of IIS logs will give you a lot of information about nature of this requests/user agent/all accessed paths/request status/...

BASKA
  • 311
  • 4
  • 15