?
Solved

Pause in HTTP POST?  Multiple threads?

Posted on 2013-06-24
4
Medium Priority
?
280 Views
Last Modified: 2013-06-25
I have a Web Request that I kick off with
Dim sendWebRequest As HttpWebRequest = CType(WebRequest.Create(stUrl), HttpWebRequest)

The headers are set up as
sendWebRequest.SendChunked = True
sendWebRequest.Method = "POST"
sendWebRequest.ContentType = "text/plain"
sendWebRequest.KeepAlive = True
sendWebRequest.UserAgent = "CometTest"

My sending posts the xml below to the stUrl (Actually in one string)
<command>
   <cmd>8889990000</cmd>
</command>
<command>
   <cmd>88899900013</cmd>
</command>
<command>
   <cmd>8889990002</cmd>
</command>
<command>
   <cmd>8889990003</cmd>
</command>
<command>
   <cmd>8889990004</cmd>
</command>
etc....

The stUrl receives these commands (which actually means to start monitoring these VOIP phones)
I then get an "Open" response stream that runs in a loop ( While streamResponse.CanRead) and sends xml to me as a phone picks up, ends call, whatever...
WHich I send on to a WCF and which posts to our callData table

Thanks to CodeCruiser's earlier help...Works perfectly

Now I've discovered that even though we have 200 phones...
And technically I can send everything to the VOIP Vendor to monitor...

On THEIR end...it takes a @1/4 second to start the monitor on each.
And the vendor is (now) limiting the "waiting monitors" to a max of 8

Is there a way to put a 3 second pause in this thing?
Can I have 200/8 threads using the same connection?

This is the request post side of it...

Dim encodedData As New ASCIIEncoding()
Dim byteArray As Byte() = encodedData.GetBytes(postData)
sendWebRequest.ContentLength = byteArray.Length

Dim newStream As Stream = sendWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
newStream.Close()

And here is how I'm consuming the response
            ' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable. 
            Using myHttpWebResponse As HttpWebResponse = CType(sendWebRequest.GetResponse(), HttpWebResponse)

                ' Displaying the contents of the page to the console 
                Using streamResponse As Stream = myHttpWebResponse.GetResponseStream()

                    'Next Line tricks into staying in Response Stream Loop
                    While streamResponse.CanRead

Open in new window

0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39272720
I guess the limit is on the connection itself so threads won't help. If vendor allows multiple connection then you may be able to send multiple requests with 8 phones being monitored with each request in its own thread. First step though is to confirm what the limit is applied to (could be connection, ip, your account etc).
0
 

Author Comment

by:lrbrister
ID: 39272790
CodeCruiser,
 I'm checking now, but am almost positive its an internal "status" on their side.

In other words, they only allow 7 requests in a "pendingStart" status.

Is it possible to do a "staged" HTTPWebRequest post?
And I'm almost positive I've used the incorrect verbiage and sound like one of the "special" people.

Forgive me Obi-Wan
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 39272859
As a test, run two instances of the exe with different xml.
0
 

Author Closing Comment

by:lrbrister
ID: 39274606
Thanks.
It's a status on their side.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question