Brian Moschel delivered this talk at the JS.Chi() April 2009 meetup. This talk provides an overview of Comet, also known as HTTP Push, covering how it works on the server and client, several implementation options, and using a new Comet API called Jabbify in an interactive demo.
5. Why Comet?
• Demand for Comet is growing
• Desktop apps moving to the web
• Chat
• Real time updates
• Don’t like to reload
• Ajax:2003::Comet:2009
6. Uses
• Multi user collaboration apps
– Wiki
– Presentation
• Communication
– Chat
• Preventing stale data
– Stock ticker
– Social web updates
• Others?
7. Polling vs. Comet
Polling
Server
Are we Are we Are we
No No No
There yet? There yet? There yet?
Client
Comet Long Polling
Server
Wait for data
Wait for data
Client
8. How Comet Works: Client Side
• Long Poll
– How?
• XHR, JSONP, or any transport, with connection held open
– Pro
• It works cross browser
– Con
• More overhead
• Forever Frame
– How?
• Iframe
• Multipart XHR
– Pro
• Less overhead, quicker responses
– Con
• Lack of error handling, not cross browser
9. Client Side Issues
• Cross Browser
– Duh
• 2 Connection Limit
– Use wildcard DNS
– Xxx.mywebsite.com -> mywebsite.com
• Synchronous request s (for JSONP)
– Long poll has to close to allow other requests to
process
10. How Comet Works: Server Side
• Simultaneous connections
– Traditional servers can’t scale
– A thread shared multiple connections
• Wake up when you’re ready to send data
11. How Comet Works: Server Side
• Python
– Orbited
– Cometd
• Java
– Jetty
• Erlang
– ErlyComet
• .NET
– Lightstreamer
• Service
– Jabbify
12. Server Side Issues
• Scaling
– Every user = 1 connection
• Complexity
– Threading
– Learning Curve
13. What is Jabbify?
• Comet, simplified
• No server
• No setup
• JavaScript API and GET requests
18. Comet is complex
• Client
– Transports (JSONP, Window.name, Flash, XHR, iframe)
• Server
– Special server
– Setup time
– Learning curve
• Scaling
– Resource consumption
– Threading issues
19. Jabbify is simple
• Client to Client Comet
– JavaScript API
• Jabbify.send(“message”,”create”,{message: “hi there”});
• Server to Client Comet
– GET requests
• https://jabbify.com/message_push?key=123&type=message...