【发布时间】:2012-02-14 15:51:18
【问题描述】:
我在我的 WCF 服务的 app.config 文件中定义这样的绑定:
<bindings>
<netTcpBinding>
<binding name="Binding1"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="524288"
maxBufferSize="524288"
maxConnections="10"
maxReceivedMessageSize="524288">
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
请注意,我已将 maxBufferSize 和 maxReceivedMessageSize 设置为 524288 字节。在我的客户项目中,当我单击“添加服务引用”时,我能够发现并添加我的服务。但它会像这样填写我客户的app.config 文件
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_AgileService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
我很好奇为什么maxBufferSize 和maxReceivedMessageSize 在我客户的app.config 中恢复为默认值。这些设置是否分别适用于客户端和服务器?换句话说,客户端和服务器可以各自有自己的消息大小限制吗?
我还需要在客户端上做些什么来确保客户端愿意发送 524288 字节的消息吗? (我只关心客户端->服务器通信)
【问题讨论】:
标签: .net wcf wcf-binding nettcpbinding