Using HostName PNRP to successfully host a WCF service?

What I'm trying to do is p2p chat application, fair and simple. It uses the same program in multiple instances on one or more computers. So no specific server / host application. Also note that I do not use a peer channel.

So this is my service host inside the chat application:

        //wcf host
        WCFService srvc= new WCFService();

        tcpUri = new Uri(string.Format("net.p2p://{0}:{1}/ProjectSandSevice", peerName.PeerHostName, port));

        NetPeerTcpBinding tcpPeerBinding = new NetPeerTcpBinding();
        tcpPeerBinding.Security.Mode = SecurityMode.None;
        tcpPeerBinding.Resolver.Mode = System.ServiceModel.PeerResolvers.PeerResolverMode.Pnrp;

        host = new ServiceHost(srvc);
        host.AddServiceEndpoint(typeof(IWCFService), tcpPeerBinding, tcpUri);
        host.Open(); 

PeerHostName (DNS name) is not safe and looks like this: "hatest-hna3l.p0.pnrp.net". Therefore, sometimes, when a chat application runs on another machine behind a different NAT (router), it does not work (PNRP finds it, but WCF cannot connect). I think this is due to a duplicate unsecured DNS name. Please note that this sometimes WORKS and sometimes DOES NOT!

, 2 PNRP, ( PNRP) ( , "hatest-hna3l.p0.pnrp.net" ) WCF.

, , WCF.

+3

All Articles