C# WCF 最大消息大小配额
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1708804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WCF Maximum Message Size Quota
提问by reustmd
I'm trying to call a WCF service (hosted in a Windows Service, not IIS) and am getting the following error:
我正在尝试调用 WCF 服务(托管在 Windows 服务中,而不是 IIS 中)并收到以下错误:
The maximum message size quota for incoming messages has been exceeded for the remote channel. See the server logs for more details.
已超出远程通道的传入消息的最大消息大小配额。有关更多详细信息,请参阅服务器日志。
I have tried increasing the MaxReceivedMessageSize and the ReaderQuotas to their maximum values without any luck.
我尝试将 MaxReceivedMessageSize 和 ReaderQuotas 增加到它们的最大值,但没有任何运气。
I have also turned on logging and checked the messsage size that's getting "sent." It's definitely nowhere near the maximum. We're talking about sending an object that serialized into 372KB XML.
我还打开了日志记录并检查了“发送”的消息大小。它绝对远不及最大值。我们正在讨论发送一个序列化为 372KB XML 的对象。
Two questions:
两个问题:
Does anyone know what "server logs" the message is referring to? I've checked the EventViewer but nothing shows up there...
Does anyone know what other configuration setting(s) might apply here?
有谁知道该消息所指的“服务器日志”是什么?我已经检查了 EventViewer 但那里没有显示任何内容...
有谁知道这里可能适用哪些其他配置设置?
采纳答案by Ben McCormack
Your question reminded me of a blog post by Shawn Wildermuth where he was having trouble with Large Message Sizes in a Silverlight application. Perhaps this will help you out:
你的问题让我想起了 Shawn Wildermuth 的一篇博客文章,他在 Silverlight 应用程序中遇到了大消息大小的问题。也许这会帮助你:
http://wildermuth.com/2009/09/10/Using_Large_Message_Requests_in_Silverlight_with_WCF
http://wildermuth.com/2009/09/10/Using_Large_Message_Requests_in_Silverlight_with_WCF
Shawn says:
肖恩 说:
The trick is to change the customBinding in the web.config to use larger defaults. I picked 2MB as it its a reasonable size. Of course setting them to 2GB like shown above will work but it does leave you more vulnerable to attacks. Pick a size that isn't larger than your largest request but isn't overly large. Its a guessing game. To set these, you need to add them to your web.config is to put them on the httpTransport node:
诀窍是更改 web.config 中的 customBinding 以使用更大的默认值。我选择了 2MB,因为它是一个合理的大小。当然,如上所示将它们设置为 2GB 会起作用,但它确实会让您更容易受到攻击。选择一个不大于您最大要求但又不过大的尺寸。它是一个猜谜游戏。要设置这些,您需要将它们添加到您的 web.config 是将它们放在 httpTransport 节点上:
回答by BennyM
I think server logs means the tracing and logging files which are created when you turn that on. Here's the MSDN link.
我认为服务器日志意味着打开它时创建的跟踪和日志记录文件。这是MSDN 链接。
The properties which I run into with WCF that need to have a higher value in the applications I write are maxReceivedMessageSize, maxStringContentLength, maxArrayLength and maxBufferSize. Try to increase them and see what happens. WCF can be a pain to debug as it is fond to swallow exceptions.
我在 WCF 中遇到的需要在我编写的应用程序中具有更高值的属性是 maxReceivedMessageSize、maxStringContentLength、maxArrayLength 和 maxBufferSize。尝试增加它们,看看会发生什么。WCF 可能很难调试,因为它喜欢吞下异常。
回答by bristows
You can specify the server logs and path in the application config as follows
您可以在应用程序配置中指定服务器日志和路径,如下所示
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Critical, Error, Warning"
>
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="F:\log-data\ServiceTrace.svclog"
/>
</listeners>
</source>
</sources>
</system.diagnostics>
回答by marc_s
Two things:
两件事情:
can you show us the server and client side config (just the relevant sections - endpoints, binding configuration)
did you change the values on both sides (client and server)??
你能向我们展示服务器和客户端的配置吗(只是相关部分 - 端点、绑定配置)
您是否更改了双方(客户端和服务器)的值??
There's a whole plethora of size settings you can influence....
您可以影响大量的尺寸设置......