IIS 7.5 托管的 WCF 服务仅针对大型请求抛出 EndpointNotFoundException 和 404
我有一个 WCF REST 服务托管在 IIS 7.5 Windows 2008 R2 上。该服务按预期工作,除非客户端尝试发送大于 ~ 25 MB 的消息。具体来说,当发送大小约为 25 MB 的消息时,服务会正确接收并处理消息,而当发送大小约为 31 MB 的消息时,服务会失败。
当在 VS 2010 本地托管时,接收消息时不会出现错误。当远程托管在 IIS 7.5 上时,服务立即响应:“System.ServiceModel.EndpointNotFoundException:没有端点正在侦听...”,内部异常是:“远程服务器返回错误:(404) 未找到” 。
这与最大消息大小设置不足时引发的异常不同。鉴于在本地托管时我没有收到错误,我的猜测是它与 IIS 或某些防火墙设置有关。
这是配置:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime requestPathInvalidCharacters="" maxRequestLength="512000"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="524288000" maxBufferSize="524288000">
<readerQuotas maxStringContentLength="524288000" maxArrayLength="524288000"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
I have a WCF REST service hosted on IIS 7.5 Windows 2008 R2. The service works as expected except when a client attempts to send a message larger than ~ 25 MB. Specifically, when sending a message size of ~ 25 MB the service receives and processes the message properly, when sending a message of size ~ 31 MB it fails.
When hosted locally on VS 2010 the message is received without error. When hosted remotely on IIS 7.5, the service immediately responds with: "System.ServiceModel.EndpointNotFoundException : There was no endpoint listening at ...", the inner exception is: "The remote server returned an error: (404) Not Found".
This is different from the exception raised when the maximum message size setting is insufficient. Given that when hosted locally I'm not getting an error my guess is that it has something to do with either IIS or perhaps some firewall settings.
This is the config:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime requestPathInvalidCharacters="" maxRequestLength="512000"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="524288000" maxBufferSize="524288000">
<readerQuotas maxStringContentLength="524288000" maxArrayLength="524288000"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IIS 的最大上传大小让您烦恼。它的默认值为 30MB。您可以在
web.config
中修复它:您也可以在 IIS 管理器中的请求过滤/功能设置中的某个位置进行更改。要修复的值为“允许的最大内容长度(字节)”。
It's the maximum upload size of IIS that bites you. It's default value is 30MB. You can fix it in
web.config
:You can also change it in the IIS manager, somewhere in Request Filtering / Feature Settings. The value to fix is "Maximum allowed content length (bytes)".
您可以尝试将最大值设置为 int max ,即 2147483648,除此之外,您可能需要考虑拆分上传或流式传输。
you can try setting your max values to int max witch is 2147483648, outside of that you may want to consider spliting the upload or streaming.