Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:56:36+00:00 2026-05-22T23:56:36+00:00

I have a simple WCF publish/subscribe up and running, based on this example .

  • 0

I have a simple WCF publish/subscribe up and running, based on this example. I am using netTcpBinding with reliableSession enabled. Everything works fine with the functionality (the subscribed clients receive the published data as expected), but at some point the connection times out if it has been idle for a while. I can set up the publisher to reconnect on timeout, but the subscribed clients will be lost. Is there a way to get them back? I would prefer not to just increase the timeouts, as that could cause other problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:56:36+00:00Added an answer on May 22, 2026 at 11:56 pm

    The solution I eventually came up with was to assign a unique identifier to every message that was published, and cache the published message in the service adapter (in the same place where I was storing the callbacks to the subscribed clients. Whenever I published the message, subscribers would receive the message and the corresponding unique id. Subscribers could then use the channel.Faulted event to reconnect and resubscribe to the service with a special method that takes the last received message id as a parameter.

    Service code:

        /// <summary>
        /// Operation used by the subscriber to subscribe to events published.
        /// </summary>
        public void Resubscribe(int lastReceivedMessageId)
        {
            // Get callback contract
            IPubSubCallback callback = OperationContext.Current.GetCallbackChannel<IPubSubCallback>();
            ThreadPool.QueueUserWorkItem(delegate(object state)
            {
                adapter.Resubscribe(lastReceivedMessageId, callback);
            }); 
        }
    

    Adapter code:

    /// <summary>
        /// Operation used by the subscriber to resubscribe to events published.
        /// </summary>
        public void Resubscribe(int lastReceivedMessageId, IPubSubCallback callback)
        {
            try
            {
                // Send the subscriber any missed messages
                foreach (KeyValuePair<int, string> missedMessage in publishedMessages.Where(x => x.Key > lastReceivedMessageId))
                {
                    callback.MessagePublished(missedMessage.Value, missedMessage.Key);
                }
    
                // Add the subscriber callback to the list of active subscribers
                if (!callbacks.Contains(callback))
                {
                    callbacks.Add(callback);
                }
            }
            catch
            {
                // ignore subscription, callbacks failed again
            }
        }
    

    The service can then work out what the client has missed, and resend those messages in the correct order.

    This solution seems to be working well for me, but I have a feeling that there must be a better way to do this. Comments / additional answers are very welcome! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple resftul wcf service. The .svc file looks like this <%@
I have a simple WCF service: public Order[] GetOrdersByStatus(int statusid) { OrderService os =
I have created a simple wcf service which used the WCF Service Library template.
I have simple regex \.*\ for me its says select everything between and ,
Ok, i have simple scenario: have two pages: login and welcome pages. im using
I have simple WCF service hosted on Windows Service. When the client of wcf
I have a simple WCF service serving up notifications to and from an app.
I have a simple WCF service that will analyse a raw text extracted from
I have a simple console app that calls a WCF service over net.tcp and
In general, is it a best practice to have simple POJO Java classes implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.