So I am currently building a service and actually everything works fine... MOSTLY!
These are really worst case scenario's. I'd rather have everything fail altogether than having something that works... Mostly.
So I have been looking on the internet, reading books, studying my code thoroughly and ultimately my boss has examined the code probably even more thorouhly. And I just can't seem to fix the problem.
The problem is as follows:
I have a WCF service that I call from a client. The service does some work, does a callback to the client and then returns to the client.
Pseudo code:
class MyService : IMyService
{
public void DoSomething()
{
}
}
service.DoSomething();
This posed to be a problem since I cannot do a callback while the client is still waiting on the service to return. I fixed this by having Visual Studio 2010 generate me a proxy with asynchronous Methods.
Caller now looks like this:
service.BeginDoSomething(null, null);
Works fine, except that while my service is doing callbacks I am doing another request to the service.
String[] arr = service.GetStrings();
And this is exactly where things go awry. This works, sometimes. GetStrings does nothing out of the ordinary. But under certain unknown circumstances the call fails, never reaches the service and causes a timeout. Shortly after that a callback from the service to the client fails. Again sometimes. 9 out of 10 times the callback is unaffected.
Not doing callbacks solves the problem, but that's not an option. Perhaps the amount of callbacks might be a problem? I am currently calling DoSomething twenty times (for test, might be 200 in production). Every call raises three callbacks, one right after DoSomething is called, the other two at a later, unspecified time.
It would be possible to call DoSomething one time and passing it an array of (for example) 200 Objects (which would cause 600 callbacks eventually).
Could it be that there is some sort of deadlock condition where my service tries to do a callback at the same time my client does another call to GetStrings and they block each other? Calling DoSomething twenty times is no problem, as long as I don't call GetStrings (GetStrings does not return void, which might make a difference). Also I am not calling GetStrings asynchronously (shouldn't be necessary).
Again, the GetStrings call goes wrong sometimes, probably a 50/50 ratio. I'm all out of idea's. I am sure I am not the only one having this problem though :)
Thanks.
Edit:
I do my callbacks as described in
this article[
^].