Solved

Pause in HTTP POST?  Multiple threads?

Posted on 2013-06-24
4
270 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 500 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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

728 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