C#/ASP.NET-远程服务器返回了意外的响应:(413)请求实体太大 [英] C#/ASP.NET - The remote server returned an unexpected response: (413) Request Entity Too Large
问题描述
我正在尝试从远程服务建立响应.在我的web.config中使用以下部分,我从Web服务中收到了不期望的响应.
I am trying to establish a response from a remote service. Using the following section in my web.config I am getting an undesired response from web service.
远程服务器返回了意外的响应:(413)请求实体太大.我尝试增加缓冲区大小,但无法克服此错误.
The remote server returned an unexpected response: (413) Request entity too large. I tried increasing the buffer size, but am unable to get past this error.
如何解决此问题?
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="CustomBinding_ISalesOrderService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<security mode="Transport"/>
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://app.vendsys2.com/VendSysAPI/v1.2/SalesOrderService.svc/VendSysAPI/v1.2/SalesReportService.svc"
binding="basicHttpBinding" bindingConfiguration="CustomBinding_ISalesOrderService"
contract="SalesOrderService.ISalesOrderService" name="CustomBinding_ISalesOrderService" />
</client>
</system.serviceModel>
推荐答案
如果客户端发送长HTTP请求,则IIS工作进程可能会接收到足够的数据来解析请求标头,但不会接收到整个请求实体.当IIS工作进程检测到需要客户端证书才能将数据返回到客户端时,IIS会尝试重新协商客户端连接.但是,客户端无法重新协商连接,因为它正在等待将剩余的请求数据发送到IIS [
If a client sends a long HTTP request the IIS worker process might receive enough data to parse request headers, but not receive the entire request entity body. When the IIS worker process detects that client certificates are required to return data to the client, IIS attempts to renegotiate the client connection. However, the client cannot renegotiate the connection because it is waiting to send the remaining request data to IIS [1]. Your problem could be just that.
来自Microsoft TechNet
Taken from Microsoft TechNet
如果请求客户端重新协商,则必须使用SSL预加载来预加载请求实体主体.SSL预加载将使用用于ISAPI扩展的UploadReadAheadSize配置数据库属性的值.但是,如果UploadReadAheadSize小于内容长度,则会返回HTTP 413错误,并关闭连接以防止死锁.(发生死锁的原因是客户端正在等待完成发送请求实体,而服务器正在等待重新协商完成,但是重新协商要求客户端能够发送数据,而它不能这样做.)
If client renegotiation is requested, the request entity body must be preloaded using SSL preload. SSL preload will use the value of the UploadReadAheadSize metabase property, which is used for ISAPI extensions. However, if UploadReadAheadSize is smaller than the content length, an HTTP 413 error is returned, and the connection is closed to prevent deadlock. (Deadlock occurs because a client is waiting to complete sending a request entity, while the server is waiting for renegotiation to complete, but renegotiation requires that the client to be able to send data, which it cannot do).
解决方案是确保不阻止客户端发送整个实体.为此,请将UploadReadAheadSize的值更改为大于内容长度的值.
The solution is to ensure that client is not blocked from sending the entire entity body. To do so, change the value of UploadReadAheadSize to a value larger than the content length.
以下示例显示了如何在Web服务器上将UploadReadAheadSize的值设置为200KB.
The following example shows how to set the value for UploadReadAheadSize to 200KB on the Web server.
cscript adsutil.vbs set w3svc/1/uploadreadaheadsize 200
请注意,在IIS 7中删除了 UploadReadAheadSize
元素,并将其作为属性添加到 serverRuntime
元素.
Be aware of that the UploadReadAheadSize
element was removed in IIS 7 and was added as an attribute to to serverRuntime
element.
这篇关于C#/ASP.NET-远程服务器返回了意外的响应:(413)请求实体太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!