WCF-NetNamedPipe's ChannelFactory

Обновите консультацию 20121214 с разработчиками службы конфликтов, они используют net.pipe://echonet в качестве адреса службы и используют DuplexChannelFactory. почему он заблокирует мою трубу?


Вопрос:

У меня очень простое приложение WCF. Сервис и Клиент через NetNamedPipe. Но странно, что некоторые машины могут быть причиной, потому что другое программное обеспечение, в результате чего ChannelFactory начал вызывать Сервис, выдает исключение: 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));
}

1 ответ

Решение
  • b1. служба, является хостом на windowsservice, запускается от имени администратора
  • Би 2. сервис, установлен net.pipe://echonet в качестве его адреса
  • b3. мой сервис, сам хост, работает как localuser

windowsservice> localuser, так что namedpipe будет перенаправлять на сервис.

  • s1. остановить службу
  • s2. смените мой сервисный хост, пусть он хостится на windowsservice.
Другие вопросы по тегам