473,386 Members | 1,758 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,386 software developers and data experts.

Futzing w/ HTTP response/request model

Hi All,

I've recently been intrigued with this notion of "Service Streaming":

http://ajaxpatterns.org/HTTP_Streaming

in which you make use of the webserver and browsers ability to maintain
a connection using a loop on the web server. I know those of you
familiar with how IIS/asp.net (aspnet_isapi.dll) handles
HttpApplication threads (a pool) are probably very offended by this
idea but I would ask that you hear me out before flaming me :)

Performance issues aside (for a moment), I have had pretty good success
implementing a handler that keeps my connection open so that in the
browser, an AJAX-style XmlHttpRequest can remain connected and respond
to onreadystatechange events as the server pushes data.

In fact, it was rather easy : in my class implementing IHttpHandler and
within the ProcessRequest method, I merely included the following:

while(loop) { if (!context.Response.IsClientConnected) loop = false; }
context.Response.End();

where "loop" is a bool initialized as true;

The implication is that we can "futz" with HTTP response/request model
to allow a web server to act as an intermediary between clients limited
only by the number of simultaneous threads (connections) a given web
server can bear. It means chat or peer-style applications over port 80.

But I am realizing that asp.net's HttpApplication is a rather
largish-object possessing a ton of overhead one really wouldn't need
for the purpose of such applications. Basically you would be stuck with
a pretty small amount of connections that you could handle on a web
server.

I found another complication (it doesn't work and I understand there
are garbage collection issues) when I tried to implement static events
on my class that inherited HttpApplication so I could inform all
connected clients of an event (hence cause a push of data to some or
all).

I've created a few HttpModules in my time and I know that it is also
bound to HttpApplication (the HttpApplication object is pushed into
event handlers implemented in your class inheriting HttpModule) and I
realize that I can't any go further up the chain of processing (to
bypass it) without writing my own C++ Isapi filters - something I hoped
to avoid. I could write my own webserver but that is also not on my
radar.

Anyway, I was hoping for advice, comments, thoughts, suggestions on the
topic because I think it is worth investigating and could usher in a
new breed of HTTP applications now that we have AJAX support in an
increasing number of browsers.

Thanks, Rein

Feb 21 '06 #1
2 1965
Rein,
Always a challenge to venture into uncharted territory, eh?

It's certainly an interesting concept, but as I am sure you already
understand, it completely goes against the whole concept of how HTTP protocol
works.

For now, I'm happy to use whatever Remote Scripting ("AJAX") implementation
to either poll or just do regular client script callbacks to refresh my DOM
on the client. There are enough problems doing that, and maintaining the
stateful context of the page, at least in ASP.NET.

I am sure there will be other comments.

My 2 cents.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Rein Petersen" wrote:
Hi All,

I've recently been intrigued with this notion of "Service Streaming":

http://ajaxpatterns.org/HTTP_Streaming

in which you make use of the webserver and browsers ability to maintain
a connection using a loop on the web server. I know those of you
familiar with how IIS/asp.net (aspnet_isapi.dll) handles
HttpApplication threads (a pool) are probably very offended by this
idea but I would ask that you hear me out before flaming me :)

Performance issues aside (for a moment), I have had pretty good success
implementing a handler that keeps my connection open so that in the
browser, an AJAX-style XmlHttpRequest can remain connected and respond
to onreadystatechange events as the server pushes data.

In fact, it was rather easy : in my class implementing IHttpHandler and
within the ProcessRequest method, I merely included the following:

while(loop) { if (!context.Response.IsClientConnected) loop = false; }
context.Response.End();

where "loop" is a bool initialized as true;

The implication is that we can "futz" with HTTP response/request model
to allow a web server to act as an intermediary between clients limited
only by the number of simultaneous threads (connections) a given web
server can bear. It means chat or peer-style applications over port 80.

But I am realizing that asp.net's HttpApplication is a rather
largish-object possessing a ton of overhead one really wouldn't need
for the purpose of such applications. Basically you would be stuck with
a pretty small amount of connections that you could handle on a web
server.

I found another complication (it doesn't work and I understand there
are garbage collection issues) when I tried to implement static events
on my class that inherited HttpApplication so I could inform all
connected clients of an event (hence cause a push of data to some or
all).

I've created a few HttpModules in my time and I know that it is also
bound to HttpApplication (the HttpApplication object is pushed into
event handlers implemented in your class inheriting HttpModule) and I
realize that I can't any go further up the chain of processing (to
bypass it) without writing my own C++ Isapi filters - something I hoped
to avoid. I could write my own webserver but that is also not on my
radar.

Anyway, I was hoping for advice, comments, thoughts, suggestions on the
topic because I think it is worth investigating and could usher in a
new breed of HTTP applications now that we have AJAX support in an
increasing number of browsers.

Thanks, Rein

Feb 22 '06 #2
Hey thanks Peter,

You're right, it is against the grain of what we have become accustomed
to with HTTP. But I find myself resisting that notion lately and
recently dug up the HTTP1.1 spec and found HTTP1.1 has allowed for
persistant connections to resolve the extra data requests (load) that
client pull presents. Check out 'Persistant Connections' section from
rfc2616:

http://www.w3.org/Protocols/rfc2616/...c8.html#sec8.1

The rfc even mentions "pipelining" requests and responses which is
exactly what I'm hoping to do to create responsive HTTP applications
that use bandwidth efficiently. Maybe this idea is not so crazy - it
seems they have opened the door to it.

But doing it with IIS is another story - I've dug and dug some more and
I can find no reasonable way of stepping in front of ASP.NET's
HttpApplicationFactory - an annoying thread pool of HttpApplication
objects that limits my ability to receive and hold onto many HTTP
connections. The only way is to drop IIS and create my own web server.

Cassini is an option - looks pretty efficient and all you have to do is
change line 132 in the source of Request.cs and replace:

HttpRuntime.ProcessRequest(this)
// 'this' is the Cassini.Request class that inherits from
SimpleWorkerRequest

with your own method call. Once you have wired up your own (static)
method to process a Cassini.Request object you have complete control. I
would still use a loop mechanism to keep the connection open but
instead use Thread.Sleep to wait for data sent from the client
(Cassini.Connection) or events raised from Cassini.Host ( this object
creates and listens on sockets for connections).

Cassini.Host uses WaitCallback to multithread the connections and as
far as I can tell, it should be able to handle some fair load because
it is very simple.

It's kind of like this server from Lightstreamer:
http://app.lightstreamer.com/StockListDemo/

It's a java server so I'm not really interested. But I think I could do
the same with .NET - it could be interesting...

Rein

Feb 22 '06 #3

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

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
3
by: Fran?ois-Xavier Testard-Vaillant | last post by:
In a Perl script I want to send several http requests WITHOUT waiting for the remote servers answer (i.e. just triggering http requests) and without having to create lots of processes... Thanks...
2
by: Vaibhav | last post by:
Hi, I am trying to write a web browser control Application in c#, i want to trap al http request and response header which are sent/recieved. I am new to Windows programming With Regards,...
11
by: Russ | last post by:
My web app writes some binary data to a file at the client site via Response.Write and Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
4
by: Bob Badger | last post by:
Hi, Simple question (although I guess with a complicated answer). Is HTTP an async protocol? For instance, if I send a message to a c# webservice via http what is the protocol actually doing? ...
3
by: Fredrik | last post by:
I want to generate a pdf file of "the current page". It is a ASP.NET aspx file created partly from GET parameters, but most often using the ASP.NET event model (i.e. clicking buttons etc). One...
1
by: Andy Fisher | last post by:
Hi all, I have a problem with a smart client in that when it makes a call to a web service, the server needs some kind of confirmation that the response has been received by the client...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.