none
WCF stops in between writing large files(approx after 20 mins). No exception is generated. RRS feed

  • Question

  • I have a WCF service hosted in iis ,which updates records in database and then creates report for updated records. I have 300 000 records.

    Database updatiion takes approx 20 mins.. It then starts creating the report and fails after putting 150 000 records or so(approximately after 20 minutes)...

    I have tried setting app pool idletimeout to zero. I have played with throttling limits too. But its not helping.

    I am giving one way call to my service from asp.net application.

    This works for lesser number of records... 


    Thursday, October 6, 2016 9:39 AM

Answers

  • Hi,  Would you be able to post the service implementation code for details of how the one way async process is kicked off and completed?.

    Also, for async tasks make sure errors are handled and logged correctly as per http://www.bartread.com/2014/02/13/c-quick-tip-does-exception-handling-work-with-async-method-calls/ . You might want to catch and log errors within the async task to troubleshoot the abort error.

    Examples of valid error handling scenarios for async (sourced from https://blogs.msdn.microsoft.com/ptorr/2014/12/10/async-exceptions-in-c)

     // Unsafe
          static void _1_VoidNoWait()
          {
            ThrowAsync();
          }
    
          // Unsafe
          static async void _2_AsyncVoidAwait()
          {
            await ThrowAsync();
          }
    
          // Safe
          static async void _3_AsyncVoidAwaitWithTry()
          {
            try { await ThrowAsync(); }
            catch (Exception ex) { Log("Exception handled OK"); }
          }
    
          // Safe only if caller uses await (or Result) inside a try
          static Task _4_TaskNoWait()
          {
            return ThrowAsync();
          }
    
          // Safe only if caller uses await (or Result) inside a try
          static async Task _5_TaskAwait()
          {
            await ThrowAsync();
          }
    
          // Helper that sets an exception asnychronously
          static Task ThrowAsync()
          {
            TaskCompletionSource tcs = new TaskCompletionSource();
            ThreadPool.QueueUserWorkItem(_ => tcs.SetException(new Exception("ThrowAsync")));
            return tcs.Task;
          }
          internal static void Log(string message, [CallerMemberName] string caller = "")
          {
            Console.WriteLine("{0}: {1}", caller, message);
          }

    Also check the event logs for an error. If not, enable WCF tracing to obtain the errors. https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx



    Thursday, October 6, 2016 11:08 PM
  • Hi Akansha,

    Thank lanax for the helpful suggestion. I suggest you try the error handling suggestion.

    In addition to timeout direction, I suggest you try idleTimeout in hostingEnvironment.

    <system.web>
        <hostingEnvironment idleTimeout="240"
                            shutdownTimeout="14400"/>
    </system.web>
    

    You could refer Listing 5-8. Web.config with hostingenvironment section for recycling settings for more information.

    To check whether it is related with IIS settings, I would suggest you try to host your service in windows service. You could refer the link below:

    # How to: Host a WCF Service in a Managed Windows Service

    https://msdn.microsoft.com/en-us/library/ms733069(v=vs.110).aspx

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, October 7, 2016 2:47 AM

All replies

  • this looks like the session timeout of 20 minutes has been reached.

    try increasing the session timeout & execution timeouts http://stackoverflow.com/questions/3829202/iis-request-timeout-on-long-asp-net-operation

    <configuration>
        ... 
        <compilation debug="false" ...>
        ... other stuff ..
    
        <location path="~/Admin/SomePage.aspx">
            <system.web>
    <!-- 240 minutes session timeout--> 
                <sessionState timeout="240" />
    <!-- 14400 seconds execution timeout--> 
                <httpRuntime executionTimeout="14400" />
            </system.web>
        </location>
        ...
    </configuration>



    • Edited by lanax Thursday, October 6, 2016 9:52 AM
    Thursday, October 6, 2016 9:48 AM
  • I tried putting below settings in the config of my service , but its not helping..

     <system.web>
      <compilation targetFramework="4.0" />
     <sessionState timeout="240" />
     <httpRuntime executionTimeout="14400" />
      </system.web>

    It breaks in between. No exception is logged. Once in a while it gives thread abort exception. If I give another one way call to service, after it has halted, it resumes, but after 20 mins or so ; it again halts.

    Thursday, October 6, 2016 11:04 AM
  • Hi,  Would you be able to post the service implementation code for details of how the one way async process is kicked off and completed?.

    Also, for async tasks make sure errors are handled and logged correctly as per http://www.bartread.com/2014/02/13/c-quick-tip-does-exception-handling-work-with-async-method-calls/ . You might want to catch and log errors within the async task to troubleshoot the abort error.

    Examples of valid error handling scenarios for async (sourced from https://blogs.msdn.microsoft.com/ptorr/2014/12/10/async-exceptions-in-c)

     // Unsafe
          static void _1_VoidNoWait()
          {
            ThrowAsync();
          }
    
          // Unsafe
          static async void _2_AsyncVoidAwait()
          {
            await ThrowAsync();
          }
    
          // Safe
          static async void _3_AsyncVoidAwaitWithTry()
          {
            try { await ThrowAsync(); }
            catch (Exception ex) { Log("Exception handled OK"); }
          }
    
          // Safe only if caller uses await (or Result) inside a try
          static Task _4_TaskNoWait()
          {
            return ThrowAsync();
          }
    
          // Safe only if caller uses await (or Result) inside a try
          static async Task _5_TaskAwait()
          {
            await ThrowAsync();
          }
    
          // Helper that sets an exception asnychronously
          static Task ThrowAsync()
          {
            TaskCompletionSource tcs = new TaskCompletionSource();
            ThreadPool.QueueUserWorkItem(_ => tcs.SetException(new Exception("ThrowAsync")));
            return tcs.Task;
          }
          internal static void Log(string message, [CallerMemberName] string caller = "")
          {
            Console.WriteLine("{0}: {1}", caller, message);
          }

    Also check the event logs for an error. If not, enable WCF tracing to obtain the errors. https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx



    Thursday, October 6, 2016 11:08 PM
  • Hi Akansha,

    Thank lanax for the helpful suggestion. I suggest you try the error handling suggestion.

    In addition to timeout direction, I suggest you try idleTimeout in hostingEnvironment.

    <system.web>
        <hostingEnvironment idleTimeout="240"
                            shutdownTimeout="14400"/>
    </system.web>
    

    You could refer Listing 5-8. Web.config with hostingenvironment section for recycling settings for more information.

    To check whether it is related with IIS settings, I would suggest you try to host your service in windows service. You could refer the link below:

    # How to: Host a WCF Service in a Managed Windows Service

    https://msdn.microsoft.com/en-us/library/ms733069(v=vs.110).aspx

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, October 7, 2016 2:47 AM