I ran into curious issue that took me a while to sort out. We are using WCF 3.5 for interconnection between modules. Some of the commands return AsyncResult
in order to be executed concurrently. I needed to write a code that executes 11 concurrent actions using WCF. Strangely, last action hanged and never arrived to the recipient module. This looked like WCF (mis-)configuration issue, and indeed it was so.
WCF asynchronous methods framework is a separate entity with complex logic and does not operate as regular methods do. For example, after BeginAction()
is called, WCF seem to keep the connection open until the action is the completed for the given AsyncResult
object. This is a WCF trace log that proves the thesis above – it took 30-60 seconds for the actions to complete, and for all this time the connection remained open (and not for couple of milliseconds it takes to create and return AsyncResult
).
By default, WCF 3.5 enforces unreasonably low concurrent connection limit of 10. In WCF 4.0 it was raised to over than 100. Combination of this limit with necessity to keep connections alive for the duration of asynchronous execution resulted in eleventh request being denied the service. Here is the article that explains how to configure concurrent connections limit to fit your needs.
Also, I added maxConnections property to the binding element:
binding name = "MyBinding" receiveTimeout = "03:00:00" sendTimeout = "03:00:00" transferMode = "Buffered" maxBufferPoolSize = "31457280" maxBufferSize = "52428800" maxReceivedMessageSize = "52428800" maxConnections = "20"
But I am not sure that this is necessary.