tags:

views:

181

answers:

2

Hi all,

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!!!

A: 

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.

Shiraz Bhaiji
A: 

" if i leave the client without accessing the WCF server I get an exception like "

May be due to inactivityTimeout, so you can increase it, or dispose your client object as soon as possible (try using statement)

you can set the property as follows

 <reliableSession ordered="true" inactivityTimeout="00:00:05"
            enabled="false" />
Ahmed Said
But if i don't want to have the inactivity time out then... I mean if the time out should be endless then can i give the value 0 or wat would be the value??? If you could say...
Jankhana
thanks for the reply I think that is the problem can you plz answer this...But if i don't want to have the inactivity time out then... I mean if the time out should be endless then can i give the value 0 or wat would be the value??? If you could say...
Jankhana
It is not recommended to do that, and if you expect that the client will work with the service rarely or not continuously you can create new instance every client request, for more details check this linkhttp://msdn.microsoft.com/en-us/library/system.servicemodel.reliablesession.inactivitytimeout.aspx
Ahmed Said