473,785 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Http WebRequest web =
(System.Net.Htt pWebRequest)Sys tem.Net.HttpWeb Request.Create( pushUrl);
web.ProtocolVer sion =
System.Net.Http Version.Version 10;
web.KeepAlive = false;
web.Credentials = new
System.Net.Netw orkCredential(s trUsername, strPassword);
web.ContentType =
"applicatio n/x-www-form-urlencoded";
web.AllowAutoRe direct = true;
web.MaximumAuto maticRedirectio ns = 5;
web.Method = "POST";
//web.Timeout = 1;

string pushxml =
"<CiscoIPPhoneE xecute><Execute Item Priority=\"0\" URL=\"" + strURI +
"\"/></CiscoIPPhoneExe cute>";
pushxml = "XML=" + HttpUtility.Url Encode(pushxml) ;

//PostData is then declared as data type Byte and
populated with the post data
byte[] PostData =
System.Text.ASC IIEncoding.ASCI I.GetBytes(push xml);

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

Stream dataStream = web.GetRequestS tream();
dataStream.Writ e(PostData, 0, PostData.Length );
dataStream.Flus h();
dataStream.Clos e();

//Send request
System.Net.Http WebResponse wResponse =
(System.Net.Htt pWebResponse)we b.GetResponse() ;
//IAsyncResult r =
(IAsyncResult)w eb.BeginGetResp onse(null, null);
//return IPPhoneReponse. Success;
//System.Net.Http WebResponse wResponse =
(System.Net.Htt pWebResponse)we b.BeginGetRespo nse(null, null);

//Convert to XmlNode
XmlDocument doc = new XmlDocument();
doc.Load(wRespo nse.GetResponse Stream());

//Handle Response
switch (doc.DocumentEl ement.Name)
{
case "CiscoIPPhoneRe sponse":
switch
(doc.SelectSing leNode("/CiscoIPPhoneRes ponse/ResponseItem"). Attributes.GetN amedItem("Data" ).Value)
{
case "Success":
return IPPhoneReponse. Success;
case "":
return IPPhoneReponse. Success;
case "Failure":
return IPPhoneReponse. Failure;
default:
return IPPhoneReponse. Failure;
}
case "CiscoIPPhoneEr ror":
if
(doc.SelectSing leNode("/CiscoIPPhoneErr or").Attributes .GetNamedItem(" Number").Value
== "4")
{
return IPPhoneReponse. AccessDenied;
}
else
{
return IPPhoneReponse. Failure;
}
default:
return IPPhoneReponse. Failure;
}
}

catch (Exception e)
{
if (e.Message.Inde xOf("timed-out") > 0)
{
return IPPhoneReponse. TimeOut;
}
if (e.Message.Inde xOf("connect") > 0)
{
Debug.WriteLine (e.Message);
return IPPhoneReponse. TimeOut;
}
else
{
return IPPhoneReponse. Failure;
}
}
Apr 24 '06 #1
7 4203
You could use threading to talk to more than one phone at once (this
will speed things up GREATLY).

Google a bit for "ThreadPool.Que ueUserWorkItem"

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.Http WebRequest web =
(System.Net.Htt pWebRequest)Sys tem.Net.HttpWeb Request.Create( pushUrl);
web.ProtocolVer sion =
System.Net.Http Version.Version 10;
web.KeepAlive = false;
web.Credentials = new
System.Net.Netw orkCredential(s trUsername, strPassword);
web.ContentType =
"applicatio n/x-www-form-urlencoded";
web.AllowAutoRe direct = true;
web.MaximumAuto maticRedirectio ns = 5;
web.Method = "POST";
//web.Timeout = 1;

string pushxml =
"<CiscoIPPhoneE xecute><Execute Item Priority=\"0\" URL=\"" + strURI +
"\"/></CiscoIPPhoneExe cute>";
pushxml = "XML=" + HttpUtility.Url Encode(pushxml) ;

//PostData is then declared as data type Byte and
populated with the post data
byte[] PostData =
System.Text.ASC IIEncoding.ASCI I.GetBytes(push xml);

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

Stream dataStream = web.GetRequestS tream();
dataStream.Writ e(PostData, 0, PostData.Length );
dataStream.Flus h();
dataStream.Clos e();

//Send request
System.Net.Http WebResponse wResponse =
(System.Net.Htt pWebResponse)we b.GetResponse() ;
//IAsyncResult r =
(IAsyncResult)w eb.BeginGetResp onse(null, null);
//return IPPhoneReponse. Success;
//System.Net.Http WebResponse wResponse =
(System.Net.Htt pWebResponse)we b.BeginGetRespo nse(null, null);

//Convert to XmlNode
XmlDocument doc = new XmlDocument();
doc.Load(wRespo nse.GetResponse Stream());

//Handle Response
switch (doc.DocumentEl ement.Name)
{
case "CiscoIPPhoneRe sponse":
switch
(doc.SelectSing leNode("/CiscoIPPhoneRes ponse/ResponseItem"). Attributes.GetN amedItem("Data" ).Value)
{
case "Success":
return IPPhoneReponse. Success;
case "":
return IPPhoneReponse. Success;
case "Failure":
return IPPhoneReponse. Failure;
default:
return IPPhoneReponse. Failure;
}
case "CiscoIPPhoneEr ror":
if
(doc.SelectSing leNode("/CiscoIPPhoneErr or").Attributes .GetNamedItem(" Number").Value
== "4")
{
return IPPhoneReponse. AccessDenied;
}
else
{
return IPPhoneReponse. Failure;
}
default:
return IPPhoneReponse. Failure;
}
}

catch (Exception e)
{
if (e.Message.Inde xOf("timed-out") > 0)
{
return IPPhoneReponse. TimeOut;
}
if (e.Message.Inde xOf("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).


BeginGetRespons e/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.25 5" 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.ne t> wrote in message
news:Ol******** ******@TK2MSFTN GP04.phx.gbl...
Hello, jeremiah!
You could use threading to talk to more than one phone at once (this
will speed things up GREATLY).


BeginGetRespons e/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.freese rve.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.Http WebRequest web =
(System.Net.Ht tpWebRequest)Sy stem.Net.HttpWe bRequest.Create (pushUrl);
web.ProtocolVer sion =
System.Net.Htt pVersion.Versio n10;
web.KeepAlive = false;
web.Credentials = new
System.Net.Net workCredential( strUsername, strPassword);
web.ContentType =
"applicatio n/x-www-form-urlencoded";
web.AllowAutoRe direct = true;
web.MaximumAuto maticRedirectio ns = 5;
web.Method = "POST";
//web.Timeout = 1;

string pushxml =
"<CiscoIPPhone Execute><Execut eItem Priority=\"0\" URL=\"" + strURI +
"\"/></CiscoIPPhoneExe cute>";
pushxml = "XML=" + HttpUtility.Url Encode(pushxml) ;

//PostData is then declared as data type Byte and
populated with the post data
byte[] PostData =
System.Text.AS CIIEncoding.ASC II.GetBytes(pus hxml);

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

Stream dataStream = web.GetRequestS tream();
dataStream.Writ e(PostData, 0, PostData.Length );
dataStream.Flus h();
dataStream.Clos e();

//Send request
System.Net.Http WebResponse wResponse =
(System.Net.Ht tpWebResponse)w eb.GetResponse( );
//IAsyncResult r =
(IAsyncResult) web.BeginGetRes ponse(null, null);
//return IPPhoneReponse. Success;
//System.Net.Http WebResponse wResponse =
(System.Net.Ht tpWebResponse)w eb.BeginGetResp onse(null, null);

//Convert to XmlNode
XmlDocument doc = new XmlDocument();
doc.Load(wRespo nse.GetResponse Stream());

//Handle Response
switch (doc.DocumentEl ement.Name)
{
case "CiscoIPPhoneRe sponse":
switch
(doc.SelectSin gleNode("/CiscoIPPhoneRes ponse/ResponseItem"). Attributes.GetN amedItem("Data" ).Value)
{
case "Success":
return IPPhoneReponse. Success;
case "":
return IPPhoneReponse. Success;
case "Failure":
return IPPhoneReponse. Failure;
default:
return IPPhoneReponse. Failure;
}
case "CiscoIPPhoneEr ror":
if
(doc.SelectSin gleNode("/CiscoIPPhoneErr or").Attributes .GetNamedItem(" Number").Value
== "4")
{
return IPPhoneReponse. AccessDenied;
}
else
{
return IPPhoneReponse. Failure;
}
default:
return IPPhoneReponse. Failure;
}
}

catch (Exception e)
{
if (e.Message.Inde xOf("timed-out") > 0)
{
return IPPhoneReponse. TimeOut;
}
if (e.Message.Inde xOf("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
1676
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 in IE using the <object> tag. My question is this. When the browser visits the pages and requests the object from the server, it appears to be making many unnecessary requests for configuration files and resources files as well. I am using the...
0
1417
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 defined a schema for details of a particular service request. Below is a schema similar to the one that I defined: <?xml version="1.0" standalone="yes" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"...
4
4603
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 does not scale to more than 200 urls or so, because it issues HTTP requests for all of the urls simultaneously, and terminates after 25 seconds. Ideally, I'd like this script to download at most 50 pages in parallel, and to time out if and only...
8
1996
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 server, but I get the problem that the two sessions are not getting updated values from each requests. Is this by design or is there any solution to do this? -- Best regards | Schöne Grüße
5
1361
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 I am finding in my debugger is that if they are backed up, I still get just one at a time. Is this just the VS 2005 integrated web server that has this behavior? -- thanks - dave
8
1790
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 one network point to another... I explain:
2
3845
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 server for updated information to show, and can also send information to the server. To do this, I have an XMLHttpRequest that queries an Asynchronous HTTP
4
2931
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 page. Example: URL: http://www.google.com/test.html Something like: urllib.urlopen('http://www.google.com/
7
3154
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 page that has two images (image A and image B) in it. Once the HTML page is served, expected behavior is this: 1) receive request for image A, 2) receive request for image B almost at the same time as for A,
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.