Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
800 views
in Technique[技术] by (71.8m points)

iis - WCF REST Service goes to sleep after inactivity

I've got a WCF REST service that is declared in a regular ASP.NET web project:

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true)]
public class BasicApp

I'm using it as a service layer for an iPhone app I'm building, so I'm requesting it using the excellent ASIHTTPRequest library.

The service itself is working just fine, but when it has been idle for approximately 10 minutes the service seems to go to sleep, which in the end gives me timeout issues on the iPhone.

If I request the service through the browser it's the same, but after 30 seconds or so the service "wakes up" and then all consecutive requests are really fast. I know I can up the timeout limit on the iPhone, but that doesn't really seem to work very well for a handheld device.

I'm guessing it's a configuration issue. The service is hosted on Win2008R2 with IIS 7.5

The IIS website is configured with it's own AppPool running .NET framework v4 with Integrated Pipeline.

Anyone has an idea how to resolve this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No need to ping your server, here is a screenshot of the setting under advanced settings for the application pool. Change Start Mode to AlwaysRunning and it will stop sleeping.

Change Start Mode to AlwaysRunning


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...