WCF - Random client timeout when making multiple calls

后端 未结 2 456
天命终不由人
天命终不由人 2021-02-06 01:39

I have a WPF client requesting data via WCF service hosted in IIS 7. The service method makes a call to a stored procedure (SQL 2012

相关标签:
2条回答
  • 2021-02-06 01:47

    As I suggested in the comments, please try setting transfermode to streamed to rule out the possibility that this is an issue related to memory pressure (since stream mode should cause wcf to utilize less memory).

    When I saw this issue suspected this might be the problem because it only seems to happen to you when making many service calls in rapid succession. In my experience this is often one of two problems: either the proxies aren't being properly closed from the client, or the server is running GC's due to memory pressure.

    When the transfermode is buffered, WCF loads the entire dataset for the message response into memory before sending it back to the client. Streamed simply sends the data back without buffering. It tends to be much faster for large data sets, slightly slower for small data sets, and always utilizes less memory(on both the server and client).

    0 讨论(0)
  • 2021-02-06 02:00

    To find out what causes your timeouts you should trace what is going on in WCF. Adding the following to your config files will generate a trace file on your client and server:

    <system.diagnostics>
       <sources>
           <source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
              <listeners>
                  <add name="xml"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="C:\logs\UserTraces.svclog" />
              </listeners>
           </source>
       </sources>
       <trace autoflush="true" /> 
    </system.diagnostics>
    

    Normally the file will tell you exactly what is going on and what fails. Make sure you have the C:\logs dir and the user has write permissions on the directory.

    Configure wcf tracing

    0 讨论(0)
提交回复
热议问题