Solved

Pause in HTTP POST?  Multiple threads?

Posted on 2013-06-24
4
251 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
  • 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now