WCF命名管道消息大小问题
我正在尝试在同一台计算机(在 XP 上)上的两个进程之间进行 WCF 命名管道通信,但我遇到了“大”消息消失的问题。消失的消息包含一个较大的字节数组,我已将故障范围缩小到数组大小约为 16k 时。比这个小,消息就能通过。比这个大,发件人说邮件正常,但从未收到。 增加发送方和接收方的缓冲区大小:
PipeServer pipeServer = new PipeServer();
ServiceHost serviceHost = new ServiceHost(pipeServer, new Uri[] { new Uri(baseName) });
NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding();
netNamedPipeBinding.MaxBufferPoolSize = 5000000;
netNamedPipeBinding.MaxBufferSize = 500000;
netNamedPipeBinding.MaxReceivedMessageSize = 500000;
serviceHost.AddServiceEndpoint(typeof(ISSNPipeServer), netNamedPipeBinding, pipeName);
我尝试按照以下服务器代码和客户端代码
_callbacks = new PipeClientCallbacks();
NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding();
netNamedPipeBinding.MaxBufferPoolSize = 5000000;
netNamedPipeBinding.MaxBufferSize = 500000;
netNamedPipeBinding.MaxReceivedMessageSize = 500000;
_pipeFactory = new DuplexChannelFactory<ISSNPipeServer>(_callbacks,
netNamedPipeBinding,
new EndpointAddress(_targetPipe));
_pipeProxy = _pipeFactory.CreateChannel();
我最终希望传输 60KB 大小的数组,但这是我第一次认真的 WCF 体验,我甚至不知道从哪里开始寻找。
I am trying to get working a WCF named pipe communication between two processes on the same computer (on XP), but I am having trouble with "large" messages disappearing. The messages that disappear contain a largish byte array and I have narrowed the failure down to when the array is around 16k in size. Smaller than that and the message gets through. Larger than that and the sender says it went fine but it is never received. I have tried bumping up the buffer sizes on both sender and receiver as per this code for the server:
PipeServer pipeServer = new PipeServer();
ServiceHost serviceHost = new ServiceHost(pipeServer, new Uri[] { new Uri(baseName) });
NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding();
netNamedPipeBinding.MaxBufferPoolSize = 5000000;
netNamedPipeBinding.MaxBufferSize = 500000;
netNamedPipeBinding.MaxReceivedMessageSize = 500000;
serviceHost.AddServiceEndpoint(typeof(ISSNPipeServer), netNamedPipeBinding, pipeName);
and this code for the client:
_callbacks = new PipeClientCallbacks();
NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding();
netNamedPipeBinding.MaxBufferPoolSize = 5000000;
netNamedPipeBinding.MaxBufferSize = 500000;
netNamedPipeBinding.MaxReceivedMessageSize = 500000;
_pipeFactory = new DuplexChannelFactory<ISSNPipeServer>(_callbacks,
netNamedPipeBinding,
new EndpointAddress(_targetPipe));
_pipeProxy = _pipeFactory.CreateChannel();
I am eventually looking to transfer arrays in the 60KB size, but this is my first serious WCF experience and I have no idea even where to really start looking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在服务器上启用WCF 跟踪以获取有关以下内容的详细信息:失败是什么。您可能仍然需要增加与绑定关联的读取器配额 (NetNamedPipeBinding.ReaderQuotas)。特别检查 MaxArrayLength 一项。
You can enable WCF tracing on the server to get more information as to what the failure is. Likely, you still need to increase the reader quotas associated with the binding (NetNamedPipeBinding.ReaderQuotas). Check the MaxArrayLength one in particular.