• Welcome to Valhalla Legends Archive.
 

Live-Streaming HTML

Started by Lenny, March 04, 2005, 10:40 PM

Previous topic - Next topic

Lenny

Is it possible to stream realtime HTML?  Do browsers still display even when it hasn't recieved all the HTML code?

Is it possible with servlets (java's answer to asp, cgi, etc)?  I'm having a bit of trouble trying to get to the lower level socket of the http connection.  All I can find are wrapper classes which builds an entire new http response everytime I flush the stream.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Adron


MyndFyre

Don't send the content-length header.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Lenny

#3
At the moment, I'm trying to find a way to send the data in realtime without having the servlet build a brand new HTTP response.  Unfortunately, the HTTP protocol is by nature unidirectional.  Anyone familiar with servlets aware of a way to get the raw HTTP socket connection?  Perhaps this belongs in the java programming forum.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

MyndFyre

Quote from: Lenny on March 05, 2005, 08:12 PM
At the moment, I'm trying to find a way to send the data in realtime without having the servlet build a brand new HTTP response.  Unfortunately, the HTTP protocol is by nature unidirectional.  Anyone familiar with servlets aware of a way to get the raw HTTP socket connection?  Perhaps this belongs in the java programming forum.

It really depends on what language you're using.  It doesn't belong on the Java forum if you're using ASP, for example.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Arta

You can do that with javascript using XMLHttpRequest/XMLHttp, if you want. It allows the client to make background HTTP requests without changing their page. Very useful for highly interactive web pages. I believe gmail uses this method.

Lenny

Well if I made something such as a chat server, the servlet being the server, I would want a broadcast message to reach the clients once the server itself receives the message.  I would prefer to not have the browser send periodical requests to see if there's a new message available on the server.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Arta

Sounds like streaming HTML for the chat window and a frame to send messages would work fine.

Lenny

That brings me back to the original problem of the servlet building a brand new http response whenever the buffer is flushed (the socket is also closed).  If I can prevent the servlet from building  a new http response, I can stream the data easily over a persistent connection.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Arta

What object are you using to generate the response? If you're using something that implements HTTP, I don't think you'll be able to get this working how you want. AFAIK, omitting content-length from your reply isn't a part of the HTTP standard: it's a bit of a hack. You should do this using Socket/ServerSocket, or something that lets you build an HTTP response yourself.

Also be aware that browers usually give up trying to load a page after a while (usually a few minutes (~10-15) in my experience). I have often gone afk from webchannel and found that IE has given up trying to load it - refreshing the page is required to see the latest chat, afer which it will stream again for a while before giving up.


MyndFyre

What you need to do is be able to hold the socket and prevent it from flushing and closing.  Combine that with not specifying the content-length header, and until the browser window is closed, you should be able to live-stream HTML.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Lenny

The server I'm working on no longer allows ServerSockets, I'm looking at GenericServlet right now.  Unlike HttpServlet, GenericServlet isn't protocol specific.

But I am aware if I stream HTTP like this I am breaking its standard convention. ;D
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Adron

You could use chunked encoding to transfer data streaming?

Ersan

I read something about this in MSDN Magazine and replicated the process, I'll see if I can find my old work, or the magazine..

MyndFyre

Quote
   All HTTP/1.1 applications that receive entities MUST accept the
   "chunked" transfer-coding (section 3.6), thus allowing this mechanism
   to be used for messages when the message length cannot be determined
   in advance.
http://www.faqs.org/rfcs/rfc2616.html
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.