WCF call from a callback thread receives TimeoutException

Posted on November 10, 2010 by

1


Symptom

In the following scenario, when performing two WCF calls, where the second call is performed from the callback thread of the first call, the second request results with a TimeoutException.

 

m_proxy.BeginAdd(3,4,(IAsyncResult ar) =>
{
    m_proxy.EndAdd(ar);
    m_proxy.Divide(8,2); // Receives TimeoutExcpetion
}, null);

What actually happens is that the first operation (Add) ends successfully, but when the second operation (Divide) is called, the call arrives to the server (and “leaves” it) , but fails completing and returning to the client. As a consequence the client always receives TimeoutException.

Solution

Sorry for the lame solution, but the only way to solve this is simply to avoid WCF calls from callback threads…

Advertisements
Posted in: Pitfalls