Solved

Pause in HTTP POST?  Multiple threads?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

11 Experts available now in Live!

Get 1:1 Help Now