views:

111

answers:

1

I have a Silverlight 3 application. It accesses WCF services that run on IIS. If I let the application sit for a while with no activity, it appears that I lose my connection to the server/login authentication, and my service calls fail.

It would appear that I am being logged out for security purposes, but this is not an area that I understand well. We are using a federated STS to create an encrypted token for security.

Can someone explain what is happening (if my description is clear enought), and how can I detect this event in my Silverlight application and redirect them back to the login page.

Thank you for any help.

+1  A: 

How are you calling the WCF service? You want to make sure that you only create and open a connection to your proxy object just before you make any calls to the WCF service, and then immediately close the connection.

Don't make a connection at the beginning of your app and then close when you're done. That will needlessly keep the service in memory. If you need to have a long running service then I suggest looking into Durable WCF Services which will let you save state between method calls.

Generally you want to treat your services as stateless and connect just before you use a method and close right after. This way you won't need to worry about when your connection closes, etc.

Terry Donaghe
How much of a performance hit is there for creating, opening, and then closing a connection, instead of leaving it open?
Sako73
I'm not sure sako - I haven't profiled that. It's gotta be better than tying up server resources. Just think if you have hundreds or thousands of clients - that would be hundreds or thousands of open services consuming resources. It seems like you'd be a lot better off just consuming resources only as needed.
Terry Donaghe