WCF service asynchronous call terminates silently and randomly

I have been working on this problem for several days and cannot find a solution :(

I have an asynchronous call to the WCF service, which will work sometimes, but in other cases it won’t do anything - without a call, without errors, nothing. It will just stop after executing my call method (main thread). Breakpoints have been added to both the service method and the auto-generated proxy class. If I debug a failed call, these breakpoints will never be deleted. In other cases (when this happens), all breakpoints will be deleted.

I completely uninstalled the service and added it again, but still no luck. I even added a new service method and request a message object in the hope that it was a problem with the original, but I am experiencing the same problem with a newly inserted method.

Just to note - this problem more often occurs when publishing my application on a virtual machine. This is not much on my local machine, but it still happens.

Here is an example of my code: -

This is an asynchronous service call;

ValidateUpdatesMessageRequest request = new ValidateUpdatesMessageRequest(); _serviceClient.ProcessUpdatesAsync(Request) 

The service method is as follows:

 public ValidateUpdatesMessageResponse ProcessUpdates(ValidateUpdatesMessageRequest request){ //method body } 

I also have an interface for the service that looks like this:

 [OperationContract] ValidateUpdatesMessageResponse ProcessUpdates(ValidateUpdatesMessageRequest request); 

I would welcome any feedback that might help me in the direction of the solution.

If you need more information, just let me know.

Thank you very much in advance!

+4
source share
3 answers

I really solved my problem.

I thought I would forward my solution to anyone who might be experiencing the same problem.

At the end of my method, which calls the async method: -

 _serviceClient.ProcessUpdatesAsync(request); 

I had

 CleanUp() 

who made the call

 _serviceClient.CloseAsync(); 

So, it closed before the service method was started.

I just took

 CleanUp() 

from the call of the orginial method to the service and put it in the method terminated by the event, thus, the asynchronous stream closes upon completion. It seems so obvious now!

Thank you for all your suggestions and materials, this is very valuable!

0
source

There are three main reasons for this:

  • Services failed, so the response is never sent. Check the server side logs.
  • There is a problem with the network that stops the call from returning. Try to control network traffic with wirehark.
  • The call returns, but no one listens. It happens that the code that was supposed to get the answer goes out of scope. Review the code to find this problem.

Hope this helps.

+1
source

There was a similar problem. In my case, the reason for this was maxArrayLength in the readerQuotas binding too low.

0
source

Source: https://habr.com/ru/post/1392908/


All Articles