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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:38:55+00:00 2026-06-17T10:38:55+00:00

we have a code below in a client app that posts data to an

  • 0

we have a code below in a client app that posts data to an HTTP listener runs on another program.

try
{
  using (WebClient client = new WebClient())
  {
     client.Encoding = System.Text.Encoding.UTF8;
     client.Credentials = new NetworkCredential(NotificationUser, NotificationPassword);
     client.UploadString(NotificationUrl, msg);  // Notification URL is IP base not DNS name.
  }
}
catch (Exception ex){}

We are testing it in a high load environment and try to stress test the request/response latency.
If I put both the programs on the same machine, I would get around 160 messages sent in one second from the posting app to the http listener app, but if I put the http listener app on different machine on the same network (a local network we create in house), that number goes down to about 5 messages/second.

Here are what we have tried so far:

  1. Ping to the 2nd machine shows it responses in less then 1ms and
    tracert shows it has only one hop. No firewall or proxy between the
    two machines.
  2. I used fiddler and StressStimulus to generate the heavy load of traffic to post to the
    listener app on another machine and I got
    (around 160 messages/second). In my opinion this rules out network latency or if the listener app is the problem.
  3. I tried to use UploadStringAsync instead of UploadString in the posting appand that did not make much different.
  4. No antivirus ect …

The weird thing is this same code works normal if the listener app is on the same machine. Does anyone know that HTTP post has any restriction or something I overlook?

  • 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-06-17T10:38:56+00:00Added an answer on June 17, 2026 at 10:38 am

    I found a question on here talking about WebClient() and HTTPWebRequest. So basically WebClient() is just a wrapper around httpwebRequest. We decided to test out my code by using HTTPWebRequest class instead.

    try
    {
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(Program.NotificationUrl);
        request.KeepAlive = false;
        request.Method = "Post";
        request.ContentType = "text/xml";
        request.Credentials = new System.Net.NetworkCredential(Program.NotificationUser, Program.NotificationPassword);
    
        byte[] data = Encoding.UTF8.GetBytes(msg);
    
        request.ContentLength = data.Length;
        Stream reqStream = request.GetRequestStream();
        reqStream.Write(data, 0, data.Length);
        reqStream.Close();
    
        WebResponse response = request.GetResponse();
        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
        {
                reader.ReadToEnd();
        }
    
    }
    catch (Exception) 
    

    Then what we found that really made the different was the flag KeepAlive. With a default value set to true, as soon as we set this flag to false, the whole http post process became lightning fast even with the authentication. If I was using WebClient class, this flag is not exposed to me and I assumed it kept the value KeepAlive=true by default.

    Hopefully someone find this information useful down the road.

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

Sidebar

Related Questions

I have code that looks more or less like the code below but it
I have the code below : public class Anything { public int Data {
We have a thick client app using jQuery heavily and want to profile the
I've got a small client/server test application where I have a Flex app that
I have a Windows 8 app that builds a string and posts to https:
I have an MVC/Nhibernate app that is giving me the below. [WrongClassException: Object with
I have an Android client that needs to authenticate with a python Google App
I have an application that consists of a Windows Phone client sending HTTP requests
I have the code below implementing a NON-Blocking TCP acceptor. Clients are able to
I have code below: <select id=testSelect> <option value=1>One</option> <option value=2>Two</option> </select> <asp:Button ID=btnTest runat=server

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.