开发者

why WCF service stop working every 20 mins?

开发者 https://www.devze.com 2023-02-27 05:39 出处:网络
I am newbie of wcf and mulit-thread, and I write a wcf service hosted in IIS7, in this service there is a long running task (System.Threading.Tasks.Task) which will probably be going to run 20 hours.

I am newbie of wcf and mulit-thread, and I write a wcf service hosted in IIS7, in this service there is a long running task (System.Threading.Tasks.Task) which will probably be going to run 20 hours.

But this wcf service always stops to work every 20 minutes.

I make the wcf send email to me when application_stop and application_start is running. Therefore, I receive a email when it start run, and then after 20 minutes, I receive the email show that the service stop.

I really cannot figure out why this happen, why the service stop work every 20 minutes.

Does the wcf services stop every 20 minutes, or the Task thread stop every 20 minutes?

Will any 开发者_JAVA百科configuration of IIS7 impact wcf running time?

I try to set the receiveTimeout to a every large time amount, and I use asych call to invoke wcf in client side, but this does not make help.

Guys, I really need help, many thanks.

Following code belongs to a website which calls this wcf service

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IMailingService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="24.20:31:23.6470000" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:92/MailingService.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IMailingService" contract="MalingService.IMailingService"
        name="BasicHttpBinding_IMailingService" />
    </client>
  </system.serviceModel>


IIS application pool idle default timeout is 20 minutes. You can configure application pool idle timeout by the below steps, which I picked from this article - http://technet.microsoft.com/en-us/library/cc771956(WS.10).aspx

  • Open IIS Manager.
  • expand the server node and click Application Pools.
  • On the Application Pools page, select the application pool for which you want to specify idle time-out settings, and then click Advanced Settings in the Actions pane.
  • In the Idle Time-out (minutes) box, type a number of minutes, and then click OK.

As rerun said, IIS host is not the best for your scenario, WAS on a Windows Service would be a better option.


IIS is a poor choice for hosting a long running task. If it is at exactly 20 minutes I would think that iis is shutting down the owner thread but that is speculation. I would really suggest moving to a windows service wcf hosting environment.


I use a cheap cron job service service to hit a handler on my app every 5 minutes. This helps keep the pool alive. If you don't want to move away from IIS, this is a quick and "dirty" fix.

0

精彩评论

暂无评论...
验证码 换一张
取 消