Ajax chat system - Active HTTP connection?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jason.m.ho@gmail.com

    #1

    Ajax chat system - Active HTTP connection?

    Hello!
    I am trying to build an ajax chat system. Currently I have it so that
    when you chat, you upload your message to the database, and each client
    is polling that database to see if he/she has any new messages. The
    problem with this is that I poll at 2 second intervals (since
    connection is not active), and so its not as responsive as I'd like it
    to be.

    My question is, is an active HTTP connection possible? How did Meebo or
    Gmail implement their ajax chat? Can someone point me to a better tool
    for implementing an active-connection chat, rather than a poll-based
    one?

    Thank You!
    - Jason

  • Jerry Stuckle

    #2
    Re: Ajax chat system - Active HTTP connection?

    jason.m.ho@gmai l.com wrote:
    Hello!
    I am trying to build an ajax chat system. Currently I have it so that
    when you chat, you upload your message to the database, and each client
    is polling that database to see if he/she has any new messages. The
    problem with this is that I poll at 2 second intervals (since
    connection is not active), and so its not as responsive as I'd like it
    to be.
    >
    My question is, is an active HTTP connection possible? How did Meebo or
    Gmail implement their ajax chat? Can someone point me to a better tool
    for implementing an active-connection chat, rather than a poll-based
    one?
    >
    Thank You!
    - Jason
    >
    No, it's not possible to continue an active HTTP connection. That's not
    how the protocol works.

    Don't know how Meebo or Gmail do it; never looked. But if I were doing
    it I'd use java.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Joseph Ferris

      #3
      Re: Ajax chat system - Active HTTP connection?


      jason.m.ho@gmai l.com wrote:
      My question is, is an active HTTP connection possible? How did Meebo or
      Gmail implement their ajax chat? Can someone point me to a better tool
      for implementing an active-connection chat, rather than a poll-based
      one?
      What you are looking for is "Reverse AJAX". In this case, the goal is
      to raise events from the server to multiple clients. One way to do it
      is to create a zero-sized frame and have a page that loads as slowly as
      possible. You basically then would slap events into the streaming HTML
      in the invisible frame, process the messages via JavaScript and send
      them to an event handler that exists in the main frame. Polling is
      another way, as you have done. Latency is the main downfall of that
      approach.

      One main caveat... Remember, that each client now has a connection
      with your server that is continually loading a page. If you are ever
      seeing a couple thousand users, at most, the networking layer on the
      server should be able to handle it. Anything more than that, probably
      not.

      Here is some further reading:


      Exploring Reverse AJAX Ajax dramatically improved the usability and interactivity of the web and the hype still goes on. But there is a new...


      And here is a resource on "slow loading" a page:


      Good luck! ;-)

      Joseph

      Comment

      Working...