473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Big perfornance problem with HTTP requests

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;
}
}
Apr 24 '06 #1
7 4190
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:
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;
}
}

Apr 24 '06 #2
Vadym Stetsyak wrote:

You're using HTTP over TCP. TCP protocol doesn't support broadcasting.


?? Yes it does...

If your subnet is 10.10.10.*, then that subnet's broadcast address is
10.10.10.255.
Apr 24 '06 #3
Actually you're right, TCP doesn't define broadcasting, IP does, because
IP defines addressing. TCP is a transmission protocol, IP is the
addressing protocol.

So yeah, neither UDP or TCP support broadcasting, its IP that supports it.

But if you're trying to say that you can't send a TCP message to a
broadcast address, you're wrong. Back in the day before broadcast
floods were common, could ping the .255 address on your network and
watch dozens and dozens of ping responses come back. Nowadays broadcast
addresses don't make it through routers at all.

jeremiah

jeremiah johnson wrote:
Vadym Stetsyak wrote:

You're using HTTP over TCP. TCP protocol doesn't support broadcasting.


?? Yes it does...

If your subnet is 10.10.10.*, then that subnet's broadcast address is
10.10.10.255.

Apr 24 '06 #4
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

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 24 '06 #5
Hello, jeremiah!

jj> But if you're trying to say that you can't send a TCP message to a
jj> broadcast address, you're wrong. Back in the day before broadcast
jj> floods were common, could ping the .255 address on your network and
jj> watch dozens and dozens of ping responses come back. Nowadays
jj> broadcast addresses don't make it through routers at all.

ICMP is not TCP. Yes you can send connection request to broadcast address, but connection is an atomic thing you cannot maintain broadcast connection, so trying to connect to "xxx.xxx.xxx.255" doesn't make sense.

.NET sockets ( stream socket -> tcp socket ) will not allow you to perform connection attempt on this address.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 24 '06 #6

"Vadym Stetsyak" <va*****@ukr.net> wrote in message
news:Ol**************@TK2MSFTNGP04.phx.gbl...
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
Apr 24 '06 #7
Thanks for all your replies. I did try the threadpool approach but it
didn't seem to work for some reason. I will try again now I know I was
on the right lines.

Thanks again,

Mike

On Mon, 24 Apr 2006 09:34:03 GMT, Mike Davies
<mike@(cutmeout)scrappy.freeserve.co.uk> wrote:
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.HttpWebRequ est.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( null, 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;
}
}

Apr 25 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris Schremser | last post by:
I have a question regarding embedded controls in IE. We are looking to replace a small VB ActiveX control with something written in C#. We have written the control and it instantiates correctly...
0
by: Matt | last post by:
I have a problem when I select node elements from an xml file and validata each node againts the schema. I use XmlValidatingReader and it complains about elements not being declared. I have...
4
by: rzimerman | last post by:
I'm hoping to write a program that will read any number of urls from stdin (1 per line), download them, and process them. So far my script (below) works well for small numbers of urls. However, it...
8
by: Michael Schwarz | last post by:
Hi, I have a problem where I have two requests (i.e. two different windows that are using the same session) that are accessing the session collection. The requests will need more time on the...
5
by: David Thielen | last post by:
I assumed that requests to my app are multi-threaded in that is there are 2 browsers making requests at the same time, I could be in the middle of responding to one when I get the next. But what...
8
by: kikapu | last post by:
Hi to all, we are building a fairly complex system here in work, and we couldn't imagine from the start that we would spend too much time just to transfer safely some kind of characters from...
2
by: dmagliola | last post by:
Hello all, I'm experiencing a problem with ASP.Net for which I can't find a reasonable explanation, or any information. I'm currently developing an application that, through AJAX, asks the...
4
by: K | last post by:
Hello everyone, I understand that urllib and urllib2 serve as really simple page request libraries. I was wondering if there is a library out there that can get the HTTP requests for a given...
7
by: =?Utf-8?B?Vkg=?= | last post by:
Hi, all. Need help with what seems to be either connection, or threading problem in my ASP.NET 2.0 application. The gist of the problem is this: IHttpHandler in my application serves an HTML...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.