Solved

Pause in HTTP POST?  Multiple threads?

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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