WCF Tracing. How I can get the exact reason for closing connection?

前端 未结 6 1158
甜味超标
甜味超标 2021-01-02 04:19

In my WCF service, when trying transfer large data I constantly get an error: The underlying connection was closed: The connection was closed unexpectedly

6条回答
  •  独厮守ぢ
    2021-01-02 04:51

    To answer your question how to create an easily trouble shooted WCF service. One way is to minimise the number of potential errors, so that you have fewer things to look at while troubleshooting.

    There are two main sources of errors:

    • An error due to the configuration
    • An exception thrown by the WCF service

    Errors in configuration are often due to a mismatch between the client and the service. To avoid this place all configuration possible in a BindingConfiguration and copy and use this on both the client and the server. This I think is actually where your problem is, you are updating the service web.config, with things that also need to be in the client config. For eaxmple the max size, or having Buffered in one and Streamed in the other.

    Errors throw by the service should be thrown as a FaultException and defined in the Contract as a FaultContract.

    For remaining errors you need to look at the trace.svclog file as described in other posts. You need also to look at the event log and IIS log, the calls may be blocked before they reach the WCF service.

提交回复
热议问题