How to send a query to the browser from time to time?

Discussion in 'Python' started by Admin, Jul 19, 2005.

  1. Admin

    Admin Guest

    I am creating a chat application like Messenger for the web (using the
    browser) and I'm wondering if there is a way to receive new messages from
    time to time from the server other than refreshing the page each 5 sec.

    If there were a way to have the server-side application send new messages
    to the browser this would be awesome because it would save dramatically on
    bandwidth. The application would consume bandwidth only when there are new
    messages. There would be no communication client-server until people write
    a new message.

    Do you know if it's possible?

    --
    Thanks,

    Admin.
    Want to buy me a book? http://tinyurl.com/78xzb :)
    Admin, Jul 19, 2005
    #1
    1. Advertising

  2. Short answer: Not using HTTP.

    However, you can use something like AJAX to just load new data from
    time to time and not the entire page.

    Or you might be able to keep the connection alive and occationally send
    stuff to the client using chunked transfer.

    I'd go for the ajax route if you don't need to support old browsers.
    Simon Dahlbacka, Jul 19, 2005
    #2
    1. Advertising

  3. Admin

    gene tani Guest

    gene tani, Jul 19, 2005
    #3
  4. Admin

    Guest

    Admin <> writes:
    > If there were a way to have the server-side application send new
    > messages to the browser this would be awesome because it would save
    > dramatically on bandwidth. The application would consume bandwidth
    > only when there are new messages. There would be no communication
    > client-server until people write a new message.
    >
    > Do you know if it's possible?


    Some people have done stuff like that with multipart mime encodings
    and chunked transfers. I've looked into it but I'm not sure of the
    exact mechanism any more. It's kind of messy.

    The other usual way is to open a tcp connection from a java applet.
    I don't like that since it means you need java in your browser.

    There's a chat app called arsc that you might look at:

    http://manuel.kiessling.net/projects/software/arsc/

    Warning, last time I looked at it, it had some security bugs.
    , Jul 19, 2005
    #4
  5. Admin

    Admin Guest

    On Tue, 19 Jul 2005 10:03:48 -0300, Simon Dahlbacka
    <> wrote:

    > I'd go for the ajax route if you don't need to support old browsers.


    I already use AJAX on several applications, but I don't want to use it in
    this one because it would poll the server a lot and it may bring the
    server down if there are many people using the chat application at the
    same time (too many queries to the database).

    --
    Thanks,

    Admin.
    Want to buy me a book? http://tinyurl.com/78xzb :)
    Admin, Jul 19, 2005
    #5
  6. Admin

    Guest

    rewrite the server to bake a /lastmsg/ folder with the last message in
    it. otherwise, my only suggestion is to use another protocol instead of
    http.
    , Jul 19, 2005
    #6
  7. Admin wrote:
    > I am creating a chat application like Messenger for the web (using the
    > browser) and I'm wondering if there is a way to receive new messages
    > from time to time from the server other than refreshing the page each 5
    > sec.


    Here's a pretty basic example I wrote a while ago using Twisted:
    <http://tw.ecritters.biz/files/twistedchat.py>. The server keeps the
    connection open and sends messages when they occur, with the side effect
    of keeping the browser's page-loading indicator alive indefinitely.
    Leif K-Brooks, Jul 20, 2005
    #7
  8. Admin

    Mike Meyer Guest

    "Simon Dahlbacka" <> writes:

    > Short answer: Not using HTTP.
    >
    > However, you can use something like AJAX to just load new data from
    > time to time and not the entire page.


    AJAX is overkill for this. If you just want to automatically refresh
    the page automatically, you can use a meta refresh tag.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Jul 20, 2005
    #8
  9. Admin

    Admin Guest

    On Wed, 20 Jul 2005 00:26:13 -0300, Mike Meyer <> wrote:

    > AJAX is overkill for this. If you just want to automatically refresh
    > the page automatically, you can use a meta refresh tag.


    Reloading the page automatically would be even worse because it would
    spend a lot of bandwidth, it would reload all the page and graphics all
    the time.

    --
    Thanks,

    Admin.
    Want to buy me a book? http://tinyurl.com/78xzb :)
    Admin, Jul 20, 2005
    #9
  10. Admin

    Admin Guest

    On Tue, 19 Jul 2005 19:43:25 -0300, <>
    wrote:

    > otherwise, my only suggestion is to use another protocol instead of
    > http.


    What do you suggest?


    --
    Thanks,

    Admin.
    Want to buy me a book? http://tinyurl.com/78xzb :)
    Admin, Jul 20, 2005
    #10
    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. msdngroup
    Replies:
    5
    Views:
    688
    msgroup
    Jan 30, 2008
  2. msdngroup
    Replies:
    0
    Views:
    569
    msdngroup
    Dec 15, 2007
  3. msdngroup
    Replies:
    5
    Views:
    344
    msgroup
    Jan 30, 2008
  4. Alpha Blue
    Replies:
    3
    Views:
    387
    Alpha Blue
    Jul 28, 2009
  5. Admin
    Replies:
    3
    Views:
    95
    Joe Smith
    Jul 21, 2005
Loading...

Share This Page