Streaming over http

Discussion in 'Java' started by Robert M. Gary, Jan 13, 2006.

  1. I'm attempting to web enable one of my java applications (for a variety
    of reasons, including the https security).

    In one case, my client expect to connect to the server long term and
    just receive async information as it happens. That doesn't seem to fit
    the http model. but I know its been done. Do you just do an HTTP_GET,
    then hang, then reissue a new HTTP_GET after each piece of data?
    DOesn't that cause a lot of disconnect/reconnects?

    -Robert
    Robert M. Gary, Jan 13, 2006
    #1
    1. Advertising

  2. Robert M. Gary wrote:
    > I'm attempting to web enable one of my java applications (for a variety
    > of reasons, including the https security).
    >
    > In one case, my client expect to connect to the server long term and
    > just receive async information as it happens.


    What happens?

    > That doesn't seem to fit
    > the http model. but I know its been done. Do you just do an HTTP_GET,
    > then hang, then reissue a new HTTP_GET after each piece of data?


    Now you are mixing the directions. Does the server send notifications,
    or does the client send requests?

    > DOesn't that cause a lot of disconnect/reconnects?


    HTTP is probably not the best protocol for a notification service. It is
    a request/response protocol. So let's assume you mean requests with long
    periods of inactivity between them.

    Protocol-wise you can keep the connection if you use an HTTP
    implementation which can do persistent connections. Even in HTTP 1.1
    persistent connections are optional, although they are highly
    recommended, and typically they are implemented.

    But that alone doesn't help. You need to keep the connection alive to
    avoid timeouts.

    However, if you requests are indeed sporadic, I don't see the need to
    keep the connection alive. Why have a connection hanging around and
    using some resources if you just once in a while use it?

    I really can't remember which HTTP version the standard library does,
    and if it does persistent connections. You have to investigate that for
    a start.

    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
    Thomas Weidenfeller, Jan 13, 2006
    #2
    1. Advertising

  3. Are there no examples of http streaming with Java? Is see a lot of
    products that advertise streaming video over http. How did those
    programmer implement their algorithms in http's traditional
    request,response,disconnect structure?

    -Robert
    Robert M. Gary, Jan 13, 2006
    #3
  4. Robert M. Gary

    Oliver Wong Guest

    "Robert M. Gary" <> wrote in message
    news:...
    > Are there no examples of http streaming with Java? Is see a lot of
    > products that advertise streaming video over http. How did those
    > programmer implement their algorithms in http's traditional
    > request,response,disconnect structure?


    I believe this is usually done with two (or more) threads, like a
    solution for the producer-consumer problem. A producer connects to a server
    via HTTP, makes a request, and starts copying the response into a buffer.
    When the consumer feels that enough data has been buffered to ensure smooth
    playback, the consumer starts consuming the buffer, and rendering it on
    screen.

    - Oliver
    Oliver Wong, Jan 13, 2006
    #4
  5. Robert M. Gary

    Roedy Green Guest

    On 13 Jan 2006 09:20:09 -0800, "Robert M. Gary" <>
    wrote, quoted or indirectly quoted someone who said :

    >Are there no examples of http streaming with Java? Is see a lot of
    >products that advertise streaming video over http. How did those
    >programmer implement their algorithms in http's traditional
    >request,response,disconnect structure?


    Streaming is best done with UDP so you just discard packets that don't
    arrive in time and do the best you can. So you are not using HTTP.

    To do it with HTTP you could just ask for a giant file, and start
    sending it. HTTP does not necessarily tell you how big the file is to
    start. The receiver buffers up x seconds before starting the video,
    and if it ever outruns the buffer, it just stops and lets the buffer
    fill again, so on a slow line in lurches along, put plays full speed
    when it can.

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Jan 14, 2006
    #5
  6. Robert M. Gary wrote:
    > Are there no examples of http streaming with Java? Is see a lot of
    > products that advertise streaming video over http. How did those
    > programmer implement their algorithms in http's traditional
    > request,response,disconnect structure?


    Streaming over HTTP is done in may different ways. Often the streaming
    in the end is not done via HTTP, but just initiated via HTTP. E.g.:

    - The server just sends an "endless" file in its response, with a
    corresponding media mime type.

    - The server sends back some proprietary data with a MIME type which is
    actually associated with some other application. The browser hands the
    data over to that other application, e.g. some media player. That other
    application interprets the data as some information on how to access a
    stream, and does so.

    - The server sends back some standardized contend description, e.g.
    SMIL. The browser hands the data over to some application which can deal
    with it.

    - The server sends back some HTML which has an embedded player object
    definition. The browser starts the player with the parameters provided
    in the HTML (one being the actual streaming source) and the player
    accesses that source.

    There are probably some more techniques.

    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
    Thomas Weidenfeller, Jan 16, 2006
    #6
  7. I think it should be something like AJAX so try to see how does it
    work.
    Haider Albassam, Jan 17, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. A.M-SG

    Streaming large files over network

    A.M-SG, Oct 28, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    647
    Steven Cheng[MSFT]
    Nov 7, 2005
  2. batista
    Replies:
    3
    Views:
    4,537
    matrixfan33
    Sep 4, 2009
  3. Nagesh
    Replies:
    2
    Views:
    9,386
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Aug 12, 2006
  4. pbienst
    Replies:
    8
    Views:
    1,332
    Gabriel Genellina
    Jan 13, 2010
  5. andrea azzini

    Problem with file streaming over HTTP

    andrea azzini, Feb 1, 2005, in forum: ASP General
    Replies:
    0
    Views:
    108
    andrea azzini
    Feb 1, 2005
Loading...

Share This Page