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 436129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:26:47+00:00 2026-05-12T20:26:47+00:00

I have a piece of code that calls a WCF service that is hosted

  • 0

I have a piece of code that calls a WCF service that is hosted on a server.

The code keeps looping around and around calling this method over and over again. (It’s asking for a ‘status’, so it’s not doing any work at all).

That’s fine except that after a short period of time I get an error:
This request operation sent to net.tcp://serverName:9001/service1 did not receive a reply within the configured timeout (00:00:09.9843754)

And suddenly i cannot get to the server at all EVER. I increased the timeout to 1min but still the same problem. Note that the program that hosts the service is doing nothing else, just offering it’s ‘status’. So it’s not an issue with the WCF service app being busy.

I think it’s a problem with the code calling the service because when i re-start the app it can connect to the service just fine … until after another short time i get the timeout error again. For this reason i don’t thnk it’s a network error either, as when I restart the app it’s ok for a period of time.

Here is the code i use to call the service. Do i need to dispose of the ChannelFactory after each call to clean it up or what am i doing worng?

        NetTcpBinding binding = new NetTcpBinding(SecurityMode.Message);
                binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

                EndpointAddress endPoint = new EndpointAddress(new Uri(clientPath));

                ChannelFactory<IClient> channel = new ChannelFactory<IClient>(binding, endPoint);
                channel.Faulted += new EventHandler(channel_Faulted);
                IClient client = channel.CreateChannel();

                ((IContextChannel)client).OperationTimeout = new TimeSpan(0, 0, 10);
                ClientStatus clientStatus = client.GetStatus();
  • 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-12T20:26:47+00:00Added an answer on May 12, 2026 at 8:26 pm

    You do have to close client connections after you finish calling GetStatus. The best way to do this is to use a using block. But you can also do something like this after your call client.GetStatus()

    ClientStatus clientStatus = client.GetStatus();
    
    try
    {
        if (client.State != System.ServiceModel.CommunicationState.Faulted)
        {
             client.Close();
        }
    }
    catch (Exception ex)
    {
        client.Abort();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
I have this piece of code that works fine in subsonic 2.2, I migrated
I have a piece of code that look similar to this: <xsl:choose> <xsl:when test=some_test>
I have this piece of code that is giving me trouble. I know all
We have a piece of legacy code that (ab)uses fopen() calls to resources over
I have a particularly ugly piece of test code that is calling a number
I have a piece of JQuery AJAX that calls a VB.NET code-behind (class) that
I've got a piece of code that calls the DeleteFile method in the Microsoft.VisualBasic.FileIO.FileSystem
I have a piece of C++ code that calls the system command.. I want
In a VS2010 package, I have a piece of code that calls FileCodeModel.CodeElements, when

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.