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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:02:35+00:00 2026-06-14T09:02:35+00:00

I’ve got a very strange problem here: There is a RESTfull web service on

  • 0

I’ve got a very strange problem here:

There is a RESTfull web service on a Python Paste web server, a WPF .net application makes a http POST request to the server every 2 seconds. The problem is that on the second call to the server, the request times out! sometimes later (say forth or fifth) requests work again and later again I get this “time out” exception!

The IntelliTrace shows that there was a blocked operation in ws2_32.dll:

A blocking operation was interrupted by a call to
WSACancelBlockingCall

I simulated the REST web server on the IIS using asp.net and the problem no longer exists, so I assume it might be the Python server config! But the Python Web Server works normally when I make the request from within the browser!

However I tried different things in the .net client application:

  • I have increased the ServicePoint’s DefaultConnectionLimit:

    ServicePointManager.DefaultConnectionLimit = 500;

  • I created a new thread for any new request to the server and aborted it when request is done!

  • I created a new AppDomain before any request and explicitly unloaded it when process is done!

  • Tried different http request headers: connection=keep-alive, accept=*

None of the above seems to work! However the funny part is that when I set a break-point to the GetRequestStream() line in VS 2012, the request dos not timeout and works properly!

Debugging the .net managed code using reflection I figured that the unmanaged recv method of the ws2_32.dll causes the operation to block and hence the web request times out!

Here’s the C# code:

static void Main(string[] args)
{
    Task.Run(() =>
    {
        while (true)
        {
            Thread.Sleep(2000);
            Console.WriteLine(PostData());
        }
    });

    Console.ReadLine();
}

public static string PostData()
{
    try
    {
        var response = "";
        var httpRequest = WebRequest.CreateHttp("http://remote_address");
        httpRequest.ServicePoint.ConnectionLimit = 500;
        httpRequest.Method = "POST";
        httpRequest.ContentType = "application/x-www-form-urlencoded";
        httpRequest.Timeout = 5000;

        using (var writer = new StreamWriter(httpRequest.GetRequestStream()))
        {
            writer.Write("req=" + "[some parameters]");
        }

        using (WebResponse httpResponse = httpRequest.GetResponse())
        {
            using (var data = httpResponse.GetResponseStream())
            {
                StreamReader sr = new StreamReader(data, Encoding.UTF8);
                response = sr.ReadToEnd();
            }

            httpResponse.Close();
        }

        return response;
    }
    catch (WebException ex)
    {
        return "time out!";
    }
}

Is there anything I can do to make this work?

  • 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-14T09:02:36+00:00Added an answer on June 14, 2026 at 9:02 am

    I managed to fix the issue with disabling Expect100Continue header:

    ServicePointManager.Expect100Continue = false;
    

    According to the HTTP 1.1 protocol, when this header is sent, client requests that use the POST method expect to receive a 100-Continue response from the server to indicate that the client should send the data to be posted.

    Having this property set to true (which is the default behavior of .Net) the data is not sent with the initial request. Instead, this header is sent to the web server which responds with 100-Continue if implemented correctly. However, not all web servers handle this correctly, including the server to which I am attempting to post data. I sniffed the headers using Fiddler and noticed that my code does send this header, while the Python Paste does not!

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

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I know there's a lot of other questions out there that deal with this
i got an object with contents of html markup in it, for example: string
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.