Testing WCF Chat application in different machines
I have a solution containing a service with two clien开发者_如何学编程ts. They can communicate with each other, send message, and fire events. They work just fine when I do a test with one machine, but I install them on different machines, internet is connected and they do not find each other. Since I am self-hosting my service could this be the reason? I use DuallHttpBinding as the binding configuration. My situation is a chat application with two client instances and one service, each of which running on different machines without having any network connection other than internet connections.
DualHttpBinding requires that the two clients be able to open connections and send messages to each other. Most likely either one of the clients is behind a firewall that can't accept incoming connections, a NAT router that isn't port forwarded, or the other client simply doesn't have the correct address to find it.
This kind of direct two-way communication over HTTP is very difficult to get right once you get onto the Internet. To debug it, I'd suggest taking a look at Fiddler which is an excellent HTTP debugging tool. You'll have to watch the connections and see if the clients can connect, and if not, why it's failing. Then you'll have to fix the connection problems that are causing that.
I'm not sure if its possible for you, but it will be significantly less error-prone to use net.tcp as your binding and have a server somewhere that all clients can connect to (as net.tcp doesn't require the server to be able to open a port back to the client, it can send using the existing connection). It only requires the client be able to connect to the server, rather then the server needing to be able to create a second connection back to the client, and thus works through standard NAT configurations.
精彩评论