问题描述
我遇到了众所周知的WCF错误:
I'm encountering the well-known WCF error:
在阅读了有关该错误的Google前五名结果之后,我仍然对我的服务/客户端的配置可能出什么问题一无所知.
After reading the top five Google results for this error, I still haven't any clue about what could be wrong with the configuration of my service/client.
我尝试过的事情:
设置maxBufferSize
和maxBufferPoolSize
.
请注意:
-
小消息可以正确传输,但是从客户端向服务器发送大消息时会发生上述错误.
Small messages are transmitted correctly, but the error above occurs when sending a large message from the client to the server.
太大的消息包含一个约350 KB的字节数组(假定WCF配置为将二进制数据编码为base64).
The message which is too large contains a ≈350 KB byte array (given that WCF is configured to encode to base64 the binary data).
这是一种(1)双向通信,其中(2)使用净TCP绑定以及(3)可靠的会话和(4)设置的顺序(这四个点与我看到的每个示例都不同)错误).
It's a (1) two-way communication which (2) uses net TCP binding with (3) reliable session and (4) ordering set on (those four points differ from every example I've seen searching for the error).
该服务由与Visual Studio 2012一起安装的IIS Express托管.
The service is hosted by IIS Express installed with Visual Studio 2012.
这是我的配置.有提示吗?
This is my configuration. Any hint?
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<bindings>
<netTcpBinding>
<binding name="netTcpEndpoint"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="DebugOrientedBehavior"
name="DemoNamespace.PipeService">
<endpoint address="Default.svc"
binding="netHttpBinding"
name="TransportLayerServiceEndpoint"
contract="DemoNamespace.IPipeService" />
<host>
<baseAddresses>
<add baseAddress="http://example.com/Default.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DebugOrientedBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
客户端配置是这样的:
<bindings>
<netHttpBinding>
<binding name="TransportLayerServiceEndpoint"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true"
enabled="false" />
<webSocketSettings transportUsage="Always" />
</binding>
</netHttpBinding>
</bindings>
<client>
<endpoint address="ws://example.com/Default.svc/Default.svc"
binding="netHttpBinding"
bindingConfiguration="TransportLayerServiceEndpoint"
contract="PipeServiceReference.IPipeService"
name="TransportLayerServiceEndpoint" />
</client>
推荐答案
您的服务配置似乎有问题-您为服务端点指定netHttpBinding
,没有bindingConfiguration,并且为netTcpBinding
定义了配置(但显然未使用).配置的相关服务部分在这里:
Your service config appears to have an issue - you specify netHttpBinding
for the service endpoint with no bindingConfiguration, and you have a configuration defined for netTcpBinding
(but apparently not used). Relevant service portion of your config here:
<endpoint address="Default.svc"
binding="netHttpBinding"
name="TransportLayerServiceEndpoint"
contract="DemoNamespace.IPipeService" />
请注意,没有设置bindingConfiguration
值.我建议将客户端中定义的绑定配置添加到您的服务配置中,然后更新服务端点以使用该绑定:
Note that there is no bindingConfiguration
value set. I would suggest adding the binding configuration defined in the client to your service config, and then updating the service endpoint to use that binding:
<endpoint address="Default.svc"
binding="netHttpBinding"
bindingConfiguration="TransportLayerServiceEndpoint"
name="TransportLayerServiceEndpoint"
contract="DemoNamespace.IPipeService" />
当前您的服务使用的是netHttpBinding
的默认值,这可能是您仍然收到错误的原因.
Currently your service is using the default values for netHttpBinding
, which is probably the reason you're still getting the error.
这篇关于为什么我仍然收到“超出了传入消息的最大消息大小配额(65536)"的信息?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!