WCF Client Timeouts
I have Silverlight application which connects to a WCF service.
If i open the open connection at the start of the application and then say give it 10 minutes or so before the client comes to call a method it will time out.
I understand that it is easy to change the timeout time in the web.config.
However what I’m looking for it for the WCF service to remain active to say 5 minutes after the soap cli开发者_开发问答ent has been closed. I though about maybe running a background thread in Silverlight which calls a WCF method which doesn’t do anything but this feels rather hacky.
Is there more of a professional way of doing this?
Thanks
You can change InstanceContextMode to signleton and start the service in the service constructor. Using signleton mode means that your session never expires.
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
Another solution is changing the InstanceContextMode to PerSession and set the InactivityTimeout to something like 1 hour.
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding" >
<reliableSession inactivityTimeout="01:00:00" enabled="true" />
</binding>
</wsHttpBinding>
</bindings>
UPDATE(After reading your comment): You can also set the inactivityTimeout="infinite".
精彩评论