WCF Session problem

wcf

I'm new to WCF and have not much idea. By using a sample code I tried WCF through remoting…

It works fine for few min but if i leave the client without accessing the WCF server I get an exception like this….

Exception:Unable to connect to the remote server.

Inner Exception :

System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 122.165.27.38:80

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)

at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)

at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

Stack Trace :

at System.Net.HttpWebRequest.GetRequestStream()

at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

at TeleMailer.TeleMailer.cbxtmuname_SelectedIndexChanged(Object sender, EventArgs e)

Source :

System

Exception :Server was unable to process request. —> The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Inner Exception :

Stack Trace :

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

at TeleMailer.Server.Service.get_path()

at TeleMailer.TeleMailer.TeleMailer_Load(Object sender, EventArgs e)

Source :

System.Web.Services

But it's not in faulted state nor it's closed!!!

Actually in my application the client communicates to the server which in turn contacts the WCF and gives him the work to do….

Right now I'm using Cassini as my server. It works great for few min but after nearly ten min it just shows this error message…. but if i restart my Cassini it works properly for few min again and gets the problem….

I cant understand how it goes to faulted state when it's able to connect more clients….

is it because the session has timed out or what? and if session has timed out then from which side from my server or client???

Any Idea plz……….

I've been siting with it for whole day but could not trace out any thing!!!

Best Answer

It may be a timeout problem, related to when you create the wcf proxy object in your client code.

It looks like you create the proxy object when you start the client and then just reuse it. This object maintains a connection to the server, which timesout after 10 min.

A better way to do it would be to create a new proxy object with a using statement, each time you need it.