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

The Archive Base Latest Questions

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

Ok. Here is the full code. I tried to reuse connections setting KeepAlive but

  • 0

Ok. Here is the full code. I tried to reuse connections setting KeepAlive but it simply doesnt work. I looked in the Http messages using Feedler and Charles but all I can see is Connection: close in response.

I see 600 TCP connections in wait state opened by 10 threads. Each thread run one http requst at a time.

There is also bunch of responses which say – the unauthenticated request. The service requires digest authentication. The code obviously is static and simply run the same request few hundred times from different threads… So why some requestes fail to be authenticated??
I

    static void GetRest(string rest)
    {
        int i = Interlocked.Increment(ref counter);

        Uri uri = new Uri(rest);
        CredentialCache cc = new CredentialCache();
        cc.Add(uri, "Digest", new NetworkCredential("zz", "zz"));

        ServicePointManager.FindServicePoint(uri).SetTcpKeepAlive(true, 6000000, 100000);
        ServicePointManager.FindServicePoint(uri).ConnectionLimit = 5;

        while (!stop)
        {

            HttpWebRequest req = WebRequest.Create(rest) as HttpWebRequest;

            req.Credentials = cc;
            req.Method = "GET";
            req.Timeout = timeout;
            req.KeepAlive = true;

            try
            {
                using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
                {
                    StreamReader sr = new StreamReader(res.GetResponseStream());

                    string result = sr.ReadToEnd().Substring(0, 20);
                    int rc = Interlocked.Increment(ref responseCounter);
                    Console.Write(".");

                    Thread.Sleep(20);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("EXCEPTION {0}, {1}", i, ex.Message);
                Interlocked.Increment(ref badResponseCounter);
            }
        }

        Interlocked.Decrement(ref counter);
    }
  • 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-15T18:25:59+00:00Added an answer on May 15, 2026 at 6:25 pm

    If you are seeing Connection: Close in the response, does this not indicate to you that the server is forcing the connection to close after every request. I’m not sure there is anything you can do at this point to change that behaviour. Maybe you could ask the service provider why they are returning Connection: Close in every response.

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

Sidebar

Related Questions

No related questions found

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.