WCF's code instances are all over the web, but there's always a lot of problems in the actual use, and I'll summarize the problems I've encountered using WCF in my project:
(Note: To see the server-side true exception configuration includeexceptiondetailinfaults= "true")
One. Phenomenon: The interface of suspended animation does not throw any exceptions (in common sense over the wait time should throw out the timeout exception but did not throw the unknown reason) or throw timeout exception.
Code environment: Winform+nettcpbinding.
Cause analysis: Because both nettcpbinding and Wshttpbinding are stateful connections, this behavior may be due to the lack of timely release of resources or the number of current sessions exceeding the MaxConcurrentSessions configuration section configuration. BasicHttpBinding is a stateless connection so this problem does not exist
Solution: Timely release of resources, increase the number of maxconcurrentsessions configuration
Two. Phenomenon: Timeout exception.
Code Environment: Winform+nettcpbinding
Cause Analysis: There are many reasons for this phenomenon 1. The acceptance information length exceeds the number of MaxReceivedMessageSize configuration section configurations. 2. Returns the array length exceeds the number of Maxarraylength configuration section configurations. 3. The number of bytes returned exceeds the Maxbytesperread configuration section configuration. 4. The return string length exceeds the number of Maxstringcontentlength configuration section configurations. 5. The number of characters that get the table name exceeds the number of Maxnametablecharcount configuration section configurations.
6. The number of items that can be serialized exceeds the number of Maxitemsinobjectgraph configuration section configurations. For example, you want to return or accept a 10-t,t containing 5 attributes (base types) or a dataset with 10 rows of 5 columns, each with 50 entries. If you do not increase the number of configurations for the Maxitemsinobjectgraph configuration section it is easy to get this error when returning to a larger list, and of course you should use a paging or batch return list to avoid passing too large a list
Solution: According to the actual situation to set the appropriate configuration section, or the use of continuous transmission, paging and other reasonable means to avoid the overrun