Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Multi Threaded WS calls hang

Multi Threaded WS calls hang

Scheduled Pinned Locked Moved C#
testingbeta-testingquestion
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stephan Meyn
    wrote on last edited by
    #1

    I am just doing a bit of load testing of a web service. I wrote several test cases in NUNIT to fire off. One test case creates several (5) threads which all start close to each other and call the web service several times. For some reason, usually only one (sometimes 2) of the threads complete, the others seem to hang. It is also never the same thread that completes. Does anyone have a clue why this may be the case? tia stephan

    A H 2 Replies Last reply
    0
    • S Stephan Meyn

      I am just doing a bit of load testing of a web service. I wrote several test cases in NUNIT to fire off. One test case creates several (5) threads which all start close to each other and call the web service several times. For some reason, usually only one (sometimes 2) of the threads complete, the others seem to hang. It is also never the same thread that completes. Does anyone have a clue why this may be the case? tia stephan

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Maybe the Web Service isn't mutli-threaded...

      1 Reply Last reply
      0
      • S Stephan Meyn

        I am just doing a bit of load testing of a web service. I wrote several test cases in NUNIT to fire off. One test case creates several (5) threads which all start close to each other and call the web service several times. For some reason, usually only one (sometimes 2) of the threads complete, the others seem to hang. It is also never the same thread that completes. Does anyone have a clue why this may be the case? tia stephan

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        Wininet.dll limits connections to an HTTP 1.0 server to 4 and to an HTTP 1.1 server to 2. See http://support.microsoft.com/default.aspx?scid=kb;en-us;320721[^] for details. Similarily, the ServierPointManager is configured to, by default, limit connections to a particular server to 2. You can change this by setting ServicePointManager.DefaultConnectionLimit to something higher, or use HttpWebRequest.ServicePoint to get the ServicePoint for a particular web address and set ServicePoint.ConnectionLimit to something higher than 2. This should apply to all connections made to a particular server. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

        S 1 Reply Last reply
        0
        • H Heath Stewart

          Wininet.dll limits connections to an HTTP 1.0 server to 4 and to an HTTP 1.1 server to 2. See http://support.microsoft.com/default.aspx?scid=kb;en-us;320721[^] for details. Similarily, the ServierPointManager is configured to, by default, limit connections to a particular server to 2. You can change this by setting ServicePointManager.DefaultConnectionLimit to something higher, or use HttpWebRequest.ServicePoint to get the ServicePoint for a particular web address and set ServicePoint.ConnectionLimit to something higher than 2. This should apply to all connections made to a particular server. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

          S Offline
          S Offline
          Stephan Meyn
          wrote on last edited by
          #4

          Maybe I am missing it - but I am not connecting from IE. This is a class dll that is running under nunit doing web service calls. it does so by creating multiple threads that all hit the same web service. Basically some threads simply stop and never return; Stephan

          D H 2 Replies Last reply
          0
          • S Stephan Meyn

            Maybe I am missing it - but I am not connecting from IE. This is a class dll that is running under nunit doing web service calls. it does so by creating multiple threads that all hit the same web service. Basically some threads simply stop and never return; Stephan

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            A WebService request is nothing but a glorified page request over HTTP or HTTPS. So, yes, your using the very same WinInet.dll that IE uses to execute and download its page requests and everything in that article applies to your problem. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            H 1 Reply Last reply
            0
            • S Stephan Meyn

              Maybe I am missing it - but I am not connecting from IE. This is a class dll that is running under nunit doing web service calls. it does so by creating multiple threads that all hit the same web service. Basically some threads simply stop and never return; Stephan

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              In .NET HTTP requests are made via HttpWebRequest (well, typically). This uses ServicePoints and a ServiePointManager to manage connections to servers. Why I explained this with wininet.dll and gave you a link is because it contains more information about why. The .NET Framework SDK documentation isn't clear on a default, so you have to dig into the IL intructions and type metadata in the assembly to know this information (which I do all the time). A web service proxy (client) uses HttpWebRequest internally and thus is prone to the same conditions that I described in my post. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

              S 2 Replies Last reply
              0
              • D Dave Kreskowiak

                A WebService request is nothing but a glorified page request over HTTP or HTTPS. So, yes, your using the very same WinInet.dll that IE uses to execute and download its page requests and everything in that article applies to your problem. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                H Offline
                H Offline
                Heath Stewart
                wrote on last edited by
                #7

                Actually, the .NET BCL doesn't use wininet.dll. That's why I explained about the ServicePoint and ServicePointManager. It's the same situation under different APIs, but the KB article explains the "why" a little better than in the .NET documentation (which doesn't even state what the default connection limit is initially set to - you have to dig into the IL - which you know I love - to find that). Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

                1 Reply Last reply
                0
                • H Heath Stewart

                  In .NET HTTP requests are made via HttpWebRequest (well, typically). This uses ServicePoints and a ServiePointManager to manage connections to servers. Why I explained this with wininet.dll and gave you a link is because it contains more information about why. The .NET Framework SDK documentation isn't clear on a default, so you have to dig into the IL intructions and type metadata in the assembly to know this information (which I do all the time). A web service proxy (client) uses HttpWebRequest internally and thus is prone to the same conditions that I described in my post. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

                  S Offline
                  S Offline
                  Stephan Meyn
                  wrote on last edited by
                  #8

                  Thanks for the info. I will check this out. At least it appears the problem is with my test code and not with the app I was testing. Stephan

                  1 Reply Last reply
                  0
                  • H Heath Stewart

                    In .NET HTTP requests are made via HttpWebRequest (well, typically). This uses ServicePoints and a ServiePointManager to manage connections to servers. Why I explained this with wininet.dll and gave you a link is because it contains more information about why. The .NET Framework SDK documentation isn't clear on a default, so you have to dig into the IL intructions and type metadata in the assembly to know this information (which I do all the time). A web service proxy (client) uses HttpWebRequest internally and thus is prone to the same conditions that I described in my post. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

                    S Offline
                    S Offline
                    Stephan Meyn
                    wrote on last edited by
                    #9

                    This did indeed fix the problem. However it does raise a question. Currently, when the number of threads trying to open simulatneous connections to the service exceed the limit, these threads go into WaitSleepJoin state. So far so good. But when the other threads close their connections, shouldn't these threads be activated by the system? At the moment the threads stay in their suspended state until they get killed by the main process (if they are background threads). Is this a bug or a feature?

                    H 1 Reply Last reply
                    0
                    • S Stephan Meyn

                      This did indeed fix the problem. However it does raise a question. Currently, when the number of threads trying to open simulatneous connections to the service exceed the limit, these threads go into WaitSleepJoin state. So far so good. But when the other threads close their connections, shouldn't these threads be activated by the system? At the moment the threads stay in their suspended state until they get killed by the main process (if they are background threads). Is this a bug or a feature?

                      H Offline
                      H Offline
                      Heath Stewart
                      wrote on last edited by
                      #10

                      Looks like they're not being signals, but without digging into the IL (and sorry to say, but it's lunch time here :)) I can't know what the problem is for sure. So I encourage you to do it. If you don't know IL and how t use ildasm.exe in the SDK, it's a great learning experience and can teach you much more about .NET than just reading docs or books. It's likely there's a bug, but don't consider it as such until you've investigated it. If I get a chance later I will look into it. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

                      S 1 Reply Last reply
                      0
                      • H Heath Stewart

                        Looks like they're not being signals, but without digging into the IL (and sorry to say, but it's lunch time here :)) I can't know what the problem is for sure. So I encourage you to do it. If you don't know IL and how t use ildasm.exe in the SDK, it's a great learning experience and can teach you much more about .NET than just reading docs or books. It's likely there's a bug, but don't consider it as such until you've investigated it. If I get a chance later I will look into it. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

                        S Offline
                        S Offline
                        Stephan Meyn
                        wrote on last edited by
                        #11

                        I have started digging around a bit starting with ServicePoint and SoapRequest. However it looks like there is quite some way to go until I'd come to the point where the threads actually are being put to sleep. I suspect it would happen somewhere in the HTTPRequest class. you might be able to shortcut this as to where in the .NET space the dispatching (and supposedly putting to sleep) is likely to occur. Unfortunately there is this thing called work getting in the way. Cheers Stephan

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups