我正在尝试在同一台计算机上的两个进程之间进行WCF命名管道通信(在XP上),但是我遇到“大”消息消失的问题。消失的消息包含一个较大的字节数组,我将故障范围缩小到数组大小约为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体验,我甚至不知道哪里真正开始寻找。
答案 0 :(得分:1)
您可以在服务器上启用WCF tracing以获取有关失败的详细信息。可能,您仍需要增加与绑定相关的阅读器配额(NetNamedPipeBinding.ReaderQuotas)。特别检查MaxArrayLength。