HTTP请求的内容长度>身体尺寸 [英] Content Length of HTTP Request > body size

查看:20
本文介绍了HTTP请求的内容长度>身体尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在管理一个网站,该网站在过去几个月通过使用 MVC 3.0 ASP.net 构建的 IIS 7.5 运行良好.当我们的 AJAX POST 请求(通过 jQuery 触发)由于发布的 JSON 被截断而失败时,我们时不时会遇到问题.

I'm managing a web site which is running fine for last couple of months over IIS 7.5 built with MVC 3.0 ASP.net. Every now and then we are facing a problem when our AJAX POST request (fired through jQuery) fails as the JSON being posted is getting truncated.

到目前为止,我们发现对于所有此类请求,请求的Content-Length"标头包含的数据比我们在请求中实际获得的数据多.

What we've found so far is that for all such request, the "Content-Length" header of the request has more data than we are actually getting in the request.

我们已经在 web.config 中将 ma​​xRequestLength 设置为 51200,我相信 ma​​xAllowedContentLength 的值有一个相当大的默认值(我们还没有设置在我们的配置中).此外,我有一个内容长度"低至 7301(字节)的失败请求,但我们设法只获得了 2179 个字节.所以我不怀疑这会达到任何限制.

We've already set maxRequestLength to 51200 in our web.config and I believe the value of maxAllowedContentLength has a pretty large default value (we've not set that in our configuration). Also I have a failed request with "Content-Length" as low as 7301 (bytes) but we managed to get only 2179 bytes of it. So I'm not suspecting this to be hitting any limit.

有问题的请求的请求头如下

Request Headers for a problematic request are as follows

  • 缓存控制:无缓存
  • 连接:保持活动
  • Pragma:无缓存
  • 内容长度:7301
  • 内容类型:应用程序/json;字符集=utf-8;
  • 接受:application/json、text/javascript、/;q=0.01
  • 接受编码:gzip、deflate
  • 接受语言:en-us,en;q=0.5
  • 用户代理:Mozilla/5.0(Windows NT 6.1;WOW64;rv:15.0)Gecko/20100101 Firefox/15.0.1
  • X-Requested-With: XMLHttpRequest

有什么想法吗??

更新:我已经能够进一步从我们的代码中分离出问题.已经编写了一个独立的控制器,它接受一个 JSON 字符串并对其进行反序列化.如果出现错误,它会记录错误.

Update : I've been able to further isolate the problem from our code. Have written an independent controller that accepts a JSON string and just deserializes it. In case of an error, it logs the error.

当我在 50 个请求的循环中与 150 个并发线程并行运行此控制器时,我会遇到一些失败,其中该控制器接收的 JSON 被截断.现在我们非常专注于优化 IIS 并阅读有关可能相关的各种参数的更多信息(目前我们在 IIS 上使用默认参数运行).

When I hit this controller in parallel with 150 concurrent threads in a loop of 50 requests then I get a few failures where the JSON that this controller receives is truncated. Now we are strongly focussed on optimizing IIS and reading more about various parameters that may be related (currently we are running with default parameters on IIS).

我强烈认为 150 个并发连接应该没什么大不了的,我真诚地希望调整一些参数我们应该能够解决这个问题.一旦我们解决了这个问题,将分享我的发现.

I strongly feel that 150 concurrent connections should not be a big deal and am sincerely hoping that tuning some parameters we should be able to get past this problem. Once we get past this problem, will share my findings.

*更新 2(10 月 8 日)*:我进一步缩小了问题的范围.我在 IIS 中打开错误日志,发现我失败的请求在读取数据时出现以下错误

*Update 2 (October 8) * : I have further narrowed down the problem. I turned on error log in IIS and discovered that my failed request gets the following error while reading data

BytesReceived = 0
ErrorCode = 2147943395
Error Description = "The I/O operation has been aborted because of either a thread exit or an application request.(0x800703e3)"

我正在 iis 论坛上查找有关此错误的信息,但我还没有尝试提供(多项)建议.以下链接可以作为搜索更多相关内容的良好起点

I am finding information about this error on iis forums but am yet to experiment with (mutliple) suggestions being given. The following link can be a good starting point for searching more on this

http://forums.iis.net/p/1149787/1917288.aspx

推荐答案

我终于找到了原因和解决方案.不幸的是,它不适用于我的所有环境,但有助于生产环境.在下面查找详细信息

I finally figured out the cause and the fix for the solution. Unfortunately it is not applicable for all my environments but helps the production environment. Find details below

事实证明这是由于 Windows 2008 R2 中的一个错误造成的,它使 asp.net 相信客户端已断开连接,即使它没有断开连接.可以在 http://support.microsoft.com/kb/977453 上找到相同的修补程序.该修复程序已经是 Windows 2008 R2 SP1 的一部分(可从 此处找到).

This turns out to be due to a bug in Windows 2008 R2, where it makes asp.net to believe that a client has disconnected even when it hasn't. A hotfix for the same is available and can be found at http://support.microsoft.com/kb/977453. The fix is already part of Windows 2008 R2 SP1 (found from here).

虽然修补程序在一个运行 Windows 2008 R2 的环境中对我有用,但它不能应用于带有 SP1 的 Windows 2008 R2.不幸的是,该问题仍然可以在 SP1 上运行的环境中重现并且仍未解决.我在 IIS 论坛上针对此问题在 http://forums.iis.net/上打开了一个新案例t/1192310.aspx 并将在那里跟踪它.

While the hotfix worked for me on one environment running Windows 2008 R2, it can not be applied to Windows 2008 R2 with SP1. Unfortunately the problem can still be reproduced on the environments running on SP1 and remains un-resolved. I have opened a new case on IIS forums for this issue at http://forums.iis.net/t/1192310.aspx and will track it there instead.

要了解有关此问题的更多信息 - 您可以关注 http://forums 上的主题.iis.net/p/1149787/1917288.aspx

To read more about this issue - you can follow the thread at http://forums.iis.net/p/1149787/1917288.aspx

这篇关于HTTP请求的内容长度>身体尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆