Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recover from
Message
From
09/09/2011 10:04:01
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
General information
Forum:
ASP.NET
Category:
Windows Communication Foundation (WCF)
Title:
Miscellaneous
Thread ID:
01523035
Message ID:
01523086
Views:
37
>>>>Hi all,
>>>>
>>>>If a Service call results in an exception because the connection is closed, (see below) does the binding and endpoint all need to be build again before a retry can be made? I could probably test this, but would have to write a bunch of code to find out and cause the failure. I was hoping someone knew the answer. Just wondering if the proxy is toast after this failure.
>>>>
>>>>
>>>>09/07/11 10:48:46|dlewis5|342560768|An existing connection was forcibly closed by the remote host in System
>>>>Stack trace:
>>>>   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
>>>>   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
>>>>Call stack:
>>>>   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
>>>>   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
>>>>
>>>>
>>>
>>>Did you just use the 'Add Service Reference' to generate the client service code ?
>>>Not that I'd know the answer to your question anyway :-{
>>
>>Hi Viv,
>>
>>Not exactly. The binding is created proxy instantiated in this factory method at runtime.
>>
>>
>>private bool CreateWebServiceProxy()
>>{
>>      if (ServiceDispatcher != null)
>>	return true;
>>
>>      // Pretest for method safety
>>      if (ServerUris == null || ServerUris.Count < 1)
>>	return false;
>>
>>      bool success = false;
>>
>>      var binding = new BasicHttpBinding
>>	{
>>		MaxBufferSize = 20 * 1024 * 1024,
>>		MaxReceivedMessageSize = 20 * 1024 * 1024,
>>		ReaderQuotas = XmlDictionaryReaderQuotas.Max
>>	};
>>
>>      foreach (string uri in ServerUris)
>>      {
>>	binding.Security.Mode = uri.ToUpper().StartsWith("HTTPS:") ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None;
>>
>>
>>	_endpoint = new EndpointAddress(uri);
>>	var customBinding = new CustomBinding(binding);
>>	BindingElementCollection elements = customBinding.CreateBindingElements();
>>
>>	foreach (var element in elements.OfType<HttpTransportBindingElement>())
>>	{
>>		(element).KeepAliveEnabled = false;
>>	}
>>
>>	ServiceDispatcher = new WSDispatcherSEIClient(customBinding, _endpoint);
>>	Global.Log.Add(LoggingDebugLevel.Hint, string.Format("Communicator.Connect: trying to connect to '{0}'...", this._endpoint));
>>
>>	success = CheckService();
>>
>>	if (success)
>>	{
>>	      _callWebServiceTotal = 0;
>>	      Global.Log.Add(LoggingDebugLevel.Hint, string.Format("Communicator.Connect: connected to '{0}'", this._endpoint));
>>
>>	      // Got a valid uri, so call it good and get out.
>>	      break;
>>	}
>>      }
>>return success;
>>}
>>
So the important bit here is the WSDispatcherSEIClient class? Is that derived from a WCF .class ?
>IAC, if I interpret this correctly, the CreateWebServiceProxy() method spins through a list of possible uri's until it finds one that works and assigns the working version to ServiceDispatcher - and it looks as if once this has run once then it will never change unless ServiceDispatcher is explicitly set to null ? The implication there being that it should not be neccessary to recreate the proxy.
>OTOH that assumption could be wrong :-{
>Sorry, just thinking aloud really, not much help......

Yes, your assumptions are correct. The WSDispatcherSEIClient is a wrapper around a WCF class. Yes it functions as you mention, however there are some error instances that are detected where the reference is set to null and the factory method is called again. The thinking is if the service goes down, there would be an opportunity to re-create where the uri could be potentially a failover uri. The question I am not so sure about is if that specific instance of the connection being closed by the remote host (most likely from a timeout) if the proxy is hosed and I should cause the instance to be set to null and recreated.
Thanks for your comments
Timothy
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform