2012-12-10 55 views
1

更新20121214 與衝突的服務的開發者協商, 他們使用net.pipe:// ECHONET作爲服務地址, 和使用DuplexChannelFactory。 爲什麼它會阻止我的管道?WCF-NetNamedPipe的的ChannelFactory


問:

我有一個非常簡單的WCF應用程序。 服務和客戶端通過NetNamedPipe通信。 但奇怪的是,有些機器可能是因爲其他軟件,導致ChannelFactory開始調用Service的其他軟件,拋出一個異常:System.ServiceModel.ProtocolException。

我怎麼知道哪個應用程序能夠捕獲我的WCF消息, 以及我應該如何避免這個問題。

這裏是例外:

System.ServiceModel.ProtocolException: The requested upgrade is not supported by 'net.pipe://localhost/xxxx/xxxx'. This could be due to mismatched bindings (for example security enabled on the client and not on the server) 

Server stack trace: 
    System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper) 
    System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper) 
    System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper) 
    System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout) 
    System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout) 
    System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout) 
    System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout) 
    System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) 
    System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: 
    System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    xxx.xxxxx.Communication.Contracts.IxxxComClientService.Register(ClientInfo clientInfo) 
    xxx.xxxxx.Communication.xxxComClient.ActionClientRegisterOnlineClientInfo(IxxxComClientService channel) 
    xxx.xxxxx.Communication.xxxComClient.ActionReceivedClientOnline(EndpointAddress endpoint) 

這裏是我的代碼」

-------------------------- - 服務------------------------------

using (var host = new ServiceHost(typeof(StringReverser), new[] { new Uri("net.pipe://localhost") })) 
{ 
    host.AddServiceEndpoint(typeof(IStringReverser), new NetNamedPipeBinding(), "PipeReverse"); 
    host.Open(); 

    Console.WriteLine("Service is available. Press <ENTER> to exit."); 
    Console.ReadLine(); 

    host.Close(); 
    } 

---------- - - - - - - - - 客戶 - - - - - - - - - - - - - - - - -

var pipeFactory = new ChannelFactory<IStringReverser>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/PipeReverse")); 
Console.WriteLine("pipeFactory Created. Press <Exit> to exit"); 
var pipeProxy = pipeFactory.CreateChannel(); 
Console.WriteLine("pipeProxy Created."); 

while (true) 
{ 
    var str = Console.ReadLine(); 
    Console.WriteLine("pipe: " + pipeProxy.ReverseString(str)); 
} 
+0

更多的例外細節? – carlosfigueira

+0

好吧,我更新我的問題。 – GeminiYellow

+0

如果說它在某些機器上可用,但在其他機器上卻不可用,那麼可能不會支持默認的'NetNamedPipeBinding'使用的安全模型的機器(基於錯誤消息)。嘗試使用新的NetNamedPipeBinding(NetNamedPipeSecurityMode.None)創建綁定,以查看此問題是否消失。 – carlosfigueira

回答

0
  • b1。該服務是Windows服務器上的主機,以管理員身份運行
  • b2。該服務,將net.pipe:// echonet設置爲他的地址
  • b3。我的服務,是自主機上,運行作爲localuser

windowsservice> localuser 所以,namedpipe會重定向到該服務。

  • s1。停止服務
  • s2。改變我的服務主機,讓它主機上 windowsservice。