user3260639
user3260639

Reputation: 158

WCF request returns wrong response

I have a c# application that the client uses wcf to talk to the server. In the background every X seconds the client calls a Ping method to the server (through WCF). The following error has reproduced a couple of times (for different method calls):

System.ServiceModel.ProtocolException: A reply message was received for operation 'MyMethodToServer' with action 'http://tempuri.org/IMyInterface/PingServerResponse'. However, your client code requires action 'http://tempuri.org/IMyInterface/MyMethodToServerResponse'.

MyMethodToServer is not consistent and it falls on different methods. How can this happen that a request receives a different response?

Upvotes: 2

Views: 1432

Answers (3)

DarkWanderer
DarkWanderer

Reputation: 8866

Wild guess: your client uses same connection to do two requests in parallel. So what happens is:

  1. Thread 1 sends request ARequest
  2. Thread 2 sends request BRequest
  3. Server sends reply BReply
  4. Thread 1 receives reply BReply while expecting AReply

If you have request logs on the server, it'll be easy to confirm - you'll likely see two requests coming with short delay from the client host experiencing the issue

I think MaxConcurrentCall and ConcurrencyMode may be relevant here (although I did not touch WCF for a long while)

Upvotes: 2

Mel Gerats
Mel Gerats

Reputation: 2262

If this occurs randomly and not you consistently, you might be running in a load-balanced setup, and deployed an update to only one of the servers?

Upvotes: 2

Leandro Bardelli
Leandro Bardelli

Reputation: 11608

I think you have a pretty mess problem with async communication, main suggestion (as your question isn't clear very well), is try to identify every request, catch the calls and waiting for them, do asyncronic communication and getting a several work with threading.

As you present it, is a typical architecture problem.

If you present more code, can I suggest some code fixing in my answer and I'll be glad to update my answer.

Upvotes: 3

Related Questions