Friday, August 25, 2006

Windows Communication Foundation + PeerChannel

One of my jobs recently required using WCF's "PeerChannel" p2p functionality for some kind of distributed system -- I didn't ask and he didn't tell, but judging by the prototype he had me mock up, it appears he's working on some kind of distributed chat-room, maybe for an existing application. This component was developed using the July CTP of .NET 3.0.

The samples included were out of date, which was really annoying -- I was basically guessing the name of the XML configuration elements, trying to get everything up and running. Eventually, though, I suceeded, after a lot of trial and error, to get everything compiling. Getting it working was another matter entirely. I can't get Microsoft's PNRP -- Peer Name Resolution Protocol -- to work properly, so I had to build my own custom peer resolver in order to get the p2p clients communicating with one another. Microsoft's PNRP is supposed to be a publically accessible way of boot-strapping p2p meshes built with WCF, but it seems to be down or just plain old broken at the moment.

Another big annoyance was the fact that p2p meshes in the July CTP can't have complex mesh names. Eg, you can have "net.p2p://CompanyName/Product/Service" as your target endpoint, but peers try to register for a mesh called "CompanyName" instead of the fully qualified path -- that can lead to a lot of collisions and headaches if you chose a generic enough word and try to use Microsoft's PNRP (or any other custom resolver, in fact). To work around this what I did was a cheap hack: "net.p2p://CompanyName.Product.Service" -- but it works. Hopefully this is an artifical limit or simply a bug in the July CTP...

By the way, Kevin Ransom's blog is a great place to find random information about WCF that you won't find the in documentation... like how to password-enable PeerChannel meshes. Did you know that since they use SSL you need to supply a freaking X509 cert just to apply a password to a PeerChannel mesh? I ended up creating a plain-jane cert using makecert.exe and just using that.

tags: , , , , ,

No comments: