无法通过 WCF 发送大消息
我使用 WCF 发送各种消息,特别是该消息大约有 3200000 字节加上一些字符串和标头。大paylode是通过另一个服务从主机检索的序列化对象,我试图在各个方面模仿该服务的配置。
我使用 netTcp 绑定来提高性能,并且我们使用了大量回调。我已将客户端和服务器端能找到的所有选项设置为最大级别。
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IEventMissionService" 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="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None" />
</binding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:7359/EventMissionMap" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEventMissionService" contract="RXEventMissionMapService.IEventMissionService" name="NetTcpBinding_IEventMissionService" />
</client>
</system.serviceModel>
我在客户端收到此非描述性错误消息:
套接字连接被中止。 这可能是由错误引起的 处理您的消息或接收 远程超时 主机或底层网络 资源问题。本地套接字超时 是“00:00:59.9979996”。
和内心的延伸:
现有连接被远程主机强制关闭
运行跟踪会带来更多信息(堆栈跟踪顶部):
System.ServiceModel.Channels.SocketConnection.Write(Byte[] 缓冲区、Int32 偏移量、Int32 大小、 布尔立即数、TimeSpan 超时) 堆栈顶部跟踪内部扩展: System.Net.Sockets.Socket.Send(字节[] 缓冲区、Int32 偏移量、Int32 大小、 SocketFlags(socketFlags)
堆栈顶部跟踪内部异常:
System.Net.Sockets.Socket.Send(字节[] 缓冲区、Int32 偏移量、Int32 大小、 SocketFlags(socketFlags)
如果我将有效负载设置为 null(不发送 3.2 MB 对象),则消息将顺利通过。
该对象源自另一个服务的事实与我的问题有什么关系吗?在我看来,问题在于消息的大小,但到目前为止,增加配置中的任何选项对我没有帮助。
我尝试在客户端上进行设置,但没有成功。 使用流式传输结果切换到请求/响应或删除所有回调...
有什么想法吗?
Im using WCF for sending all sorts of messages and this message in perticular is about 3200000 bytes plus some strings and headers. The large paylode is a serialized object retrieved from the host through another service whos configuration I have tried to mimic in every aspect.
Im using netTcp binding for performance and we are using lots of callbacks. I have set all options I can find to the maximum level on both client and server side.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IEventMissionService" 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="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None" />
</binding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:7359/EventMissionMap" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEventMissionService" contract="RXEventMissionMapService.IEventMissionService" name="NetTcpBinding_IEventMissionService" />
</client>
</system.serviceModel>
I get this non-descript error message on the client:
The socket connection was aborted.
This could be caused by an error
processing your message or a receive
timeout being exceeded by the remote
host, or an underlying network
resource issue. Local socket timeout
was '00:00:59.9979996'.
And inner exteption:
An existing connection was forcibly closed by the remote host
Running trace brings a bit more information (top of stack trace):
System.ServiceModel.Channels.SocketConnection.Write(Byte[]
buffer, Int32 offset, Int32 size,
Boolean immediate, TimeSpan timeout)
Top of stack trace inner exteption:
System.Net.Sockets.Socket.Send(Byte[]
buffer, Int32 offset, Int32 size,
SocketFlags socketFlags)
Top of stack trace inner exception:
System.Net.Sockets.Socket.Send(Byte[]
buffer, Int32 offset, Int32 size,
SocketFlags socketFlags)
If I set the payload to null (not sending the 3.2 MB object) the message goes through without any fuss.
Can the fact that the object originates from another service has anything to with my problem? In my eyes the problem is the size of the message but increasing any options in the configuration has not helped me so far.
I have tried to set on the client with no luck.
Using streaming results in switching to request/respons or removing all callbacks...
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我错了!!我在主机端的配置级别上所做的更改是针对完全不同的服务。最大化缓冲区大小和消息大小就可以了!我不太确定是哪一个让它发挥作用。我只能建议所有有类似问题的人查看 MaxBufferSize、MaxReceivedMessageSize、ReaderQuotas->MaxArrayLength 以及主机和客户端上的一些超时设置。还要最大化主机端服务行为中的 maxItemsInObjectGraph。
I was wrong!! The changes I made on the configuration levels on the host side was on a completely different service. Maximizing the buffer sizes and message sizes did the trick! Im not really sure which one is the one that made it work. I can only recommend all of you that have similar problems to look at MaxBufferSize, MaxReceivedMessageSize, ReaderQuotas->MaxArrayLength and some time out settings both on host and client side. Also to maximize the maxItemsInObjectGraph in the service behavior on the host side.