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

  • Home
  • SEARCH
  • 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 6602171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:50:43+00:00 2026-05-25T18:50:43+00:00

I have a WCF service hosted within a Windows service. There is s method

  • 0

I have a WCF service hosted within a Windows service. There is s method in the WCF service that will raise an event that the Windows service subscribes to. When the event is raised and the Windows service catches it, the Windows service calls another WCF method to send a message to all connected clients. For some reason when I have all these these happen in this sequence an error is thrown:

This request operation sent to http://localhost:8731/Design_Time_Addresses/WCF/WCFService/ did not receive a reply within the configured timeout (00:00:29.9939996)....

Here is the relevant code from teh WCF service:

public event EventHandler<CustomEventArgs> CustomEvent;

private static readonly List<IMessageCallback> subscribers = new List<IMessageCallback>();

public void SendMessageToClients(string msgType, string message)
{
    subscribers.ForEach(delegate(IMessageCallback callback)
    {
        if (((ICommunicationObject)callback).State == CommunicationState.Opened)
        {
            callback.OnMessageReceived(msgType, message, DateTime.Now);
        }
        else
        {
            subscribers.Remove(callback);
        }
    });
}

public bool messageHost()
{
    try
    {
        if (CustomEvent != null)
            CustomEvent(null, new CustomEventArgs());
        return true;
    }
    catch
    {
        return false;
    }
}

And the Code from the Windows service:

wcfService = new WCF.WCFService();
sHost = new ServiceHost(wcfService);
wcfService.CustomEvent += new EventHandler<WCF.CustomEventArgs>(wcfService_CustomEvent);
sHost.Open();

private void wcfService_CustomEvent(object source, WCF.CustomEventArgs e)
{
    wcfService.SendMessageToClients("log", "CLient connected!!");
    osae.AddToLog("client message"); //just writes to a log file
}

And the client just calls this:

wcfObj.messageHost();

Here is the client config:

  <system.serviceModel>
<bindings>
  <wsDualHttpBinding>
    <binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:00:10"
      openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:00:30"
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
      textEncoding="utf-8" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" />
      <security mode="Message">
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
          algorithmSuite="Default" />
      </security>
    </binding>
  </wsDualHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/"
    binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService"
    contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</client>

And the service config:

<system.serviceModel>
<services>
  <service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
    <endpoint address="" binding="wsDualHttpBinding" contract="WCF.IWCFService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint
      address="mex"
      binding="mexHttpBinding"
      bindingConfiguration=""
      contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

If I remove the SendMessageToClients call from the event in the Windows service it works and just logs the ‘client message’ as expected. Also, when the error is thrown about the timeout I can click continue and the the client continues to run and it received the message from the host. Why is the strange behavior happening?

EDIT:
Marc led me to search in the right place: http://www.codeproject.com/KB/WCF/WCF_Duplex_UI_Threads.aspx

  • 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-25T18:50:44+00:00Added an answer on May 25, 2026 at 6:50 pm

    The symptoms here suggest to me like there is a deadlock happening, perhaps due to a sync-context (WCF respects sync-context by default). Meaning: the outward message is waiting on access to the context, but it is itself the thing that the existing context is waiting on.

    The easiest way to investigate that would be to perform the outward message on a worker thread:

    ThreadPool.QueueUserWorkItem(delegate {
        wcfObj.messageHost();
    });
    

    I believe you can also configure WCF to change how it approaches sync-context, but I can’t remember how…

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

Sidebar

Related Questions

We have created a WCF service hosted in a windows service that handles Authentication
I have a WCF service that is hosted in a windows application. The service
I have a WCF Service that I have written, which is hosted within a
I have a web application that is talking to a WCF service hosted within
I have a WCF service hosted within a Windows service. Its purpose is to
I have an wcf service that is hosted in II6. The service uses the
I have a WCF service which will be hosted under IIS. Now I have
I have a WCF service, hosted in IIS 7.0 that needs to run database
I have a self hosted WCF Rest service that I am using to simulate
I have a WCF service hosted on my local machine as windows service. Now

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.