简体   繁体   English

WCF 请求返回错误响应

[英]WCF request returns wrong response

I have ac# application that the client uses wcf to talk to the server.我有客户端使用 wcf 与服务器通信的 ac# 应用程序。 In the background every X seconds the client calls a Ping method to the server (through WCF).在后台,客户端每隔 X 秒向服务器调用一个 Ping 方法(通过 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'. System.ServiceModel.ProtocolException:收到操作“MyMethodToServer”的回复消息,操作为“http://tempuri.org/IMyInterface/PingServerResponse”。 However, your client code requires action 'http://tempuri.org/IMyInterface/MyMethodToServerResponse'.但是,您的客户端代码需要操作“http://tempuri.org/IMyInterface/MyMethodToServerResponse”。

MyMethodToServer is not consistent and it falls on different methods. MyMethodToServer 并不一致,它属于不同的方法。 How can this happen that a request receives a different response?请求收到不同的响应怎么会发生这种情况?

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.如果您提供更多代码,我可以在我的答案中建议一些代码修复吗,我很乐意更新我的答案。

如果这种情况是随机发生的,而不是一直发生,那么您可能正在负载平衡的设置中运行,并且仅将更新部署到其中一台服务器?

Wild guess: your client uses same connection to do two requests in parallel.疯狂猜测:您的客户端使用相同的连接并行执行两个请求。 So what happens is:那么会发生什么:

  1. Thread 1 sends request ARequest线程 1 发送请求 ARequest
  2. Thread 2 sends request BRequest线程 2 发送请求 BRequest
  3. Server sends reply BReply服务器发送回复 BReply
  4. Thread 1 receives reply BReply while expecting AReply线程 1 在期待 AReply 时收到回复 BReply

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)我认为MaxConcurrentCallConcurrencyMode可能与此处有关(虽然我很长时间没有接触 WCF)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM