WebService request are stucked Intermitantly, async mode RRS feed

  • Question

  • We have a web service client, that run the multiple web service requests in parallel, with default connection limit(ServicePointManager.DefaultConnectionLimit) which is 10.

    Intermittently the actions aren't able to completely success due to random one or two requests out of 100+ requests made stucked in requesting mode. For those request with problem also showing no response header code nor timeout message in Fiddler's session.

    We set the DefaultConnectionLimit to 1 for troubleshooting, above situation then never occurred.

    Our project is using .NET Framework 4.5.2, Task.StartNew() method to evaluate above requests. Generally most of the request are able to response within 10 sec, is there any better way beside adding the estimated timeout and handle it? My second question is why above request will stucked intermittently and randomly in async mode?


    • Moved by Fei Hu Sunday, December 24, 2017 7:53 AM Web technology related
    Tuesday, December 5, 2017 12:59 PM

All replies

  • Network requests can stall for any # of reasons including the remote server locks or runs out of connections. Based upon your troubleshooting scenario I'd wager the remote server is having issues with handling simultaneous requests. You should contact the implementor to get help with this. 

    You don't really want to try to fire up 100+ requests at once because of the connection limit. You'll end up timing out requests potentially before they can get handled. I'd recommend that you batch send requests. You can, for example, use the LimitedConcurrencyLevelTaskScheduler to limit the # of requests to, say 10, then send your requests and wait for them to all complete. This will allow the requests to occur in batches and may help prevent the issue you're seeing. The nice thing about this approach is that you can continue to use a standard for loop because the scheduler will simply block the add request until there is room. Hence your code reads and works the way you want but the scheduler will still throttle the request count.

    Note that if the request is successfully sent then you should be getting a timeout if it takes too long to run. You need to be handling this error if you're not already.

    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, December 6, 2017 2:46 PM
  • Hello Moooon2,

    You issue is more related to web request, you could post a new thread to ASP.NET Forum for suitable support. If you have some grammar or code errors in using C#, please feel free to contact us. We will try our best to give you a solution.


    Neil Hu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Sunday, December 24, 2017 7:51 AM