1
votes

I have a WCF service hosted inside a Windows service. and I am using NetTcpBinding to connect a WPF client application to this service. I have a callback contract to allow push notifications back to the client, which is working just fine, except when there is more than one client running on the same machine (for example, two client instances running in separate remote desktop sessions). In those circumstances, it appears that only one of the clients is receiving the callback messages. It seems that the problem is caused by the two clients exposing the same callback address, and so the message only goes to one of the listeners.

For example, let's say I have my WCF service hosted on machine 'fakeserver' and 2 WPF clients both running on machine 'fakeclient'. The address that clients use to connect to the WCF service is 'net.tcp://fakeserver:1234/MyService'. Both clients are able to connect to the service just fine. But when the server sends a callback, it's going to send it to 'net.tcp://fakeclient:1234/MyCallback' (since NetTcpBinding is duplex by default, we don't have to specify a separate port for sending callbacks), which has two different clients listening for traffic. Only one of those clients receives the message.

If I were using WSDualHttpBinding, I would be able to specify different ports for the client callback address, thus making the two client callback addresses unique. As it stands, though, I believe both client callback addresses are the same, which is why the message only goes to one client (the last one registered, usually).

How can I ensure that two (or more) WPF clients on the same machine are treated distinctly and each receive any callback messages pushed by the service while still using NetTcpBinding?

1
I am confused. Are you saying that you are storing two instances of the callback delegate on the service, one per client, and you call both of them one after the other but only one client receives the call? - tom redfern
Yes, Tom, that is correct. When a new client session is kicked off, I'm having it register with the service. The service stores the callback proxy, and when it needs to notify all clients it loops through the proxies to broadcast a message out. When I have two clients on the same machine, though, the messages are only being sent to one client, not both. - virsum
Just spin up different instances of the client from within the same session. Why does this need to work across remote sessions? - tom redfern
Tom, please see my updated example. - virsum

1 Answers

1
votes

It turns out all the callbacks were able to be called from the same machine. The callbacks were being stored uniquely by machine name, so the second time we registered a callback it was replacing the first callback.