大网数据广告活动
Web服务器与PHP

ShutdownTimeLimit doesn't apply to WCF

· 52CE 我爱测

This article provides workarounds for the problem where IIS application pool ShutdownTimeLimit recycle property does not apply to WAS-hosted WCF services using net.tcp.

This article helps you resolve the problem where Microsoft Internet Information Services (IIS) application pool ShutdownTimeLimit recycle property doesn't apply to WAS-hosted Communication Foundation (WCF) services by using net.tcp.

Original product version:   Internet Information Services
Original KB number:   2819362

Symptoms

After implementing a Windows WCF service hosted by the Windows Activation Service (WAS), the IIS application pool assigned to the application has a recycle shutdown time ShutdownTimeLimit set to 90 seconds. This allows the WCF service time to complete any active work items should the application pool be recycled. However, when the application recycle occurs the existing worker process shuts down prior to 90 seconds, preventing the active work from completing.

Cause

This behavior is by design.

Net.tcp behaves differently than Hypertext Transfer Protocol (HTTP) in the presence of an IIS application pool recycle and aborts the connection before the ShutdownTimeLimit timer is reached, shutting down the worker process that was handling the request. HTTP applications will honor the ShutdownTimeLimit timer however net.tcp applications do not.

The underlying problem is that when the IIS application pool recycle occurs the session information for the net.tcp channel is lost. When the application pool is restarted it can reopen an HTTP channel as IIS handles the channel information, however for the net.tcp connection it is SMSvcHost.exe that actually controls this channel. IIS does not re-engage the SMSvcHost.exe to reopen the channel. At that point, the client connection has been closed and the client must restart the communication.

The net.tcp WAS implementation uses SMSvcHost.exe to listen for incoming TCP requests. When received, SMSvcHost.exe sets up an internal named-pipe connection to invoke the corresponding WCF service. This is effectively an invisible duplex channel. When the IIS application pool is recycled, session state information is lost and the named-pipe duplex connection is broken. A hard-coded one-minute timeout inside SMSvcHost.exe eventually aborts the socket connection.

This has two consequences:

  • The client channel gets a socket exception and must be reopened to be used again.
  • The WCF operation that was running gets aborted before the normal IIS ShutdownTimeLimit timer value. The broken duplex connection causes WCF to abort the operation.

Workaround

To work around this issue, consider a way to queue the necessary cleanup work somewhere not reliant on session state as opposed to relying on the IIS ShutdownTimeLimit interval to do necessary cleanup work in a fixed period of time.

More information

It is also advised to install a hotfix from Microsoft Connect Has Been Retired. However, it does not resolve this issue. It avoids a related issue where SMSvcHost.exe stops responding to all requests.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 04/07/2020
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。