HighTechTalks DotNet Forums  

Re: Big perfornance problem with HTTP requests

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss Re: Big perfornance problem with HTTP requests in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
jeremiah johnson
 
Posts: n/a

Default Re: Big perfornance problem with HTTP requests - 04-24-2006 , 06:41 AM






You could use threading to talk to more than one phone at once (this
will speed things up GREATLY).

Google a bit for "ThreadPool.QueueUserWorkItem"

You could maybe also send your HTTP request to the subnet broadcast
address, which would address every network node on that subnet
simultaneously. You wouldn't be able to listen for responses, but it
might suit your needs. Talk to your friendly neighborhood networking
person for more about that.

jeremiah();


Mike Davies wrote:
Quote:
Hi,

I'm developing an APP which pushed web content to various devices on a
LAN (these devices happen to be IP phones).

I need to broadcast a HTTP message to maybe 100 phones at a time but
this is really slow. I've tried different things but not sure what the
right way to go is. First way is to push the message to the phone but
this takes anywhere from 500ms to 1000ms to complete. Incidentally,
I'm not interested in the repsonse from the phone.

The other way I tried was to wait for the response asynchronously but
that didn't seem to work and was still quite slow at around 100ms.

I can't figure out how to push a message to all phones simultaenously
while ignoreing the repsonse. Can anyone point me in the right
direction.

Just to reiterate, I'm not interested in the response even though the
code below checks for a response. This is just because druing testing
I wanted to know if the phone received it or not. My problem is how do
I send a HTTP request to 100 phones at the same time and ignore the
response.

Cheers,


Mike



try
{
/
//Build URL to post execute command to
string pushUrl = "http://" + strDeviceIP +
"/CGI/Execute";

//The Following Creates the WebClient Object
System.Net.HttpWebRequest web =
(System.Net.HttpWebRequest)System.Net.HttpWebReque st.Create(pushUrl);
web.ProtocolVersion =
System.Net.HttpVersion.Version10;
web.KeepAlive = false;
web.Credentials = new
System.Net.NetworkCredential(strUsername, strPassword);
web.ContentType =
"application/x-www-form-urlencoded";
web.AllowAutoRedirect = true;
web.MaximumAutomaticRedirections = 5;
web.Method = "POST";
//web.Timeout = 1;

string pushxml =
"<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\" URL=\"" + strURI +
"\"/></CiscoIPPhoneExecute>";
pushxml = "XML=" + HttpUtility.UrlEncode(pushxml);

//PostData is then declared as data type Byte and
populated with the post data
byte[] PostData =
System.Text.ASCIIEncoding.ASCII.GetBytes(pushxml);

//Send POST data (XML)
web.ContentLength = PostData.Length;

Stream dataStream = web.GetRequestStream();
dataStream.Write(PostData, 0, PostData.Length);
dataStream.Flush();
dataStream.Close();

//Send request
System.Net.HttpWebResponse wResponse =
(System.Net.HttpWebResponse)web.GetResponse();
//IAsyncResult r =
(IAsyncResult)web.BeginGetResponse(null, null);
//return IPPhoneReponse.Success;
//System.Net.HttpWebResponse wResponse =
(System.Net.HttpWebResponse)web.BeginGetResponse(n ull, null);

//Convert to XmlNode
XmlDocument doc = new XmlDocument();
doc.Load(wResponse.GetResponseStream());

//Handle Response
switch (doc.DocumentElement.Name)
{
case "CiscoIPPhoneResponse":
switch
(doc.SelectSingleNode("/CiscoIPPhoneResponse/ResponseItem").Attributes.GetNamedItem("Data").Val ue)
{
case "Success":
return IPPhoneReponse.Success;
case "":
return IPPhoneReponse.Success;
case "Failure":
return IPPhoneReponse.Failure;
default:
return IPPhoneReponse.Failure;
}
case "CiscoIPPhoneError":
if
(doc.SelectSingleNode("/CiscoIPPhoneError").Attributes.GetNamedItem("Numbe r").Value
== "4")
{
return IPPhoneReponse.AccessDenied;
}
else
{
return IPPhoneReponse.Failure;
}
default:
return IPPhoneReponse.Failure;
}
}

catch (Exception e)
{
if (e.Message.IndexOf("timed-out") > 0)
{
return IPPhoneReponse.TimeOut;
}
if (e.Message.IndexOf("connect") > 0)
{
Debug.WriteLine(e.Message);
return IPPhoneReponse.TimeOut;
}
else
{
return IPPhoneReponse.Failure;
}
}

Reply With Quote
  #2  
Old   
Vadym Stetsyak
 
Posts: n/a

Default Re: Big perfornance problem with HTTP requests - 04-24-2006 , 07:06 AM






Hello, jeremiah!

Quote:
You could use threading to talk to more than one phone at once (this
will speed things up GREATLY).

BeginGetResponse/EndGetResponse use ThreadPool internally

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Reply With Quote
  #3  
Old   
David Browne
 
Posts: n/a

Default Re: Big perfornance problem with HTTP requests - 04-24-2006 , 01:59 PM




"Vadym Stetsyak" <vadym_s (AT) ukr (DOT) net> wrote

Quote:
Hello, jeremiah!

You could use threading to talk to more than one phone at once (this
will speed things up GREATLY).

BeginGetResponse/EndGetResponse use ThreadPool internally

You can always spawn/join threads or use a custom thread pool.

eg

Abortable Thread Pool
http://msdn.microsoft.com/msdnmag/is...03/NETMatters/

David




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.