Note that there are some explanatory texts on larger screens.

plurals
  1. POException in Publisher Subscriber model while working in WCF
    primarykey
    data
    text
    <p>I have made a WCF publisher Subscriber service which handles 70 to 80 connections per day If a connection breaks in between ( due to internet connection failure , System shutdown etc.) the service itself will try to set up a connection itself when the connectivity resumes.</p> <p>sometime back I am noticed my service is throwing exceptions (operation Timed out)</p> <p><strong><code>This request operation sent to net.tcp://localhost:2001/sub did not receive a reply within the configured timeout (00:00:59.9799877). The time allotted to this operation may have been a portion of a longer timeout. This may be because the service is still processing the operation or because the service was unable to send a reply message. Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client</code></strong></p> <p>and then after some of these Exceptions RM destination time out exceptions are coming up which faults the line for further communication with the service</p> <p><strong>The request to create a reliable session has been refused by the RM Destination. Server 'net.tcp://localhost:2001/Sub' is too busy to process this request. Try again later. The channel could not be opened</strong>.</p> <p>During this time the the clients already subscribed are responding successfully to the pub sub requests </p> <p>No new Channels are subscribing to the service</p> <p>I am using net Tcp binding in the Service </p> <p>client code </p> <pre><code> public class Subscriber : IPublishing { static int Counter = 0; ISubscription _proxy; string _endpoint = string.Empty; public Subscriber() { _endpoint = "net.tcp://localhost:2001/sub"; MakeProxy(_endpoint, this); } void MakeProxy(string EndpoindAddress, object callbackinstance) { try { NetTcpBinding netTcpbinding = new NetTcpBinding(SecurityMode.None); EndpointAddress endpointAddress = new EndpointAddress(EndpoindAddress); InstanceContext context = new InstanceContext(callbackinstance); // Added for Reliable communication netTcpbinding.ReliableSession.Enabled = true; netTcpbinding.ReliableSession.Ordered = true; netTcpbinding.MaxBufferSize = 2147483647; netTcpbinding.MaxBufferPoolSize = 2147483647; netTcpbinding.MaxReceivedMessageSize = 2147483647; netTcpbinding.ReliableSession.InactivityTimeout = TimeSpan.MaxValue; netTcpbinding.ReceiveTimeout = TimeSpan.MaxValue; DuplexChannelFactory&lt;ISubscription&gt; channelFactory = new DuplexChannelFactory&lt;ISubscription&gt;(new InstanceContext(this), netTcpbinding, endpointAddress); _proxy = channelFactory.CreateChannel(); Counter++; } catch (Exception ex) { // } } public void Subscribe() { try { _proxy.Subscribe("500"); Counter = 0; } catch (Exception ex) { ((IContextChannel)_proxy).Abort(); } } public void Publish(Message e, String ID) { } public void _Subscribe() { try { //OnUnSubscribe(); Subscribe(); } catch (Exception ex) { } } } </code></pre> <p>Server Code </p> <pre><code>[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] class Subscription : ISubscription { #region ISubscription Members public void Subscribe(string ID) { String s = DateTime.Now.ToString( IPublishing subscriber = OperationContext.Current.GetCallbackChannel&lt;IPublishing&gt;(); Filter.AddSubscriber(KioskID, subscriber); } public void UnSubscribe(string ID) { IPublishing subscriber = OperationContext.Current.GetCallbackChannel&lt;IPublishing&gt;(); Filter.RemoveSubscriber(KioskID, subscriber); } #endregion } class Filter { static Dictionary&lt;string, List&lt;IPublishing&gt;&gt; _subscribersList = new Dictionary&lt;string, List&lt;IPublishing&gt;&gt;(); static public Dictionary&lt;string, List&lt;IPublishing&gt;&gt; SubscribersList { get { lock (typeof(Filter)) { return _subscribersList; } } } static public List&lt;IPublishing&gt; GetSubscribers(String topicName) { lock (typeof(Filter)) { if (SubscribersList.ContainsKey(topicName)) { return SubscribersList[topicName]; } else return null; } } static public void AddSubscriber(String topicName, IPublishing subscriberCallbackReference) { DebugLog.WriteLog("C:\\DevPubSubServiceLogs", topicName + "came for Sub"); lock (typeof(Filter)) { DebugLog.WriteLog("C:\\DevPubSubServiceLogs",topicName + "inside lock"); if (SubscribersList.ContainsKey(topicName)) { // Removing any stray subscribers for same topic name // because only 1 subscriber for 1 topic name should exist SubscribersList.Remove(topicName); } List&lt;IPublishing&gt; newSubscribersList = new List&lt;IPublishing&gt;(); newSubscribersList.Add(subscriberCallbackReference); SubscribersList.Add(topicName, newSubscribersList); } DebugLog.WriteLog("C:\\DevPubSubServiceLogs", topicName + "subscribed"); } static public void RemoveSubscriber(String topicName, IPublishing subscriberCallbackReference) { lock (typeof(Filter)) { if (SubscribersList.ContainsKey(topicName)) { //if (SubscribersList[topicName].Contains(subscriberCallbackReference)) //{ // SubscribersList[topicName].Remove(subscriberCallbackReference); //} SubscribersList.Remove(topicName); } } } } </code></pre> <p>Contracts </p> <pre><code>[ServiceContract] public interface IPublishing { [OperationContract(IsOneWay = true)] void Publish(Message e, string ID); } [ServiceContract(CallbackContract = typeof(IPublishing))] public interface ISubscription { [OperationContract] void Subscribe(string topicName); [OperationContract] void UnSubscribe(string topicName); } </code></pre> <p>Please assist..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload