From Seo Wiki - Search Engine Optimization and Programming Languages
In theory, the Comet approach differs from the original model of the web, in which a browser requests a complete web page or chunks of data to update a web page. However in practice, Comet applications typically use Ajax with long polling to detect new information on the server. The concept predates the coining of the neologism, and is known by several other names, including Ajax Push, Reverse Ajax, Two-way-web, HTTP Streaming, and HTTP server push among others.
|This section is in need of attention from an expert on the subject. WikiProject Technology may be able to help recruit one. (October 2008)|
Comet is an umbrella term for technologies that attempt to eliminate both the limitations of the page-by-page web model and traditional polling. Comet-like applications offer real-time interaction by relying on a persistent HTTP connection (or where not possible a long lasting HTTP connection) to provide the browser with updates as designated by the web application. Since browsers and proxies are not designed with server events in mind, web application developers have tried to work around several unintended side-effects to implement Comet-like behavior, each with different benefits and drawbacks. In particular, the HTTP 1.1 specification states that a browser should not have more than 2 simultaneous connections with a web server. However, holding one connection open for real-time events has a negative impact on browser usability. The browser may be blocked from sending a new request while it still loads, for example, a series of images. This can be worked around by creating a distinct hostname for real-time information, which is an alias for the same physical server.
Specific methods of implementing Comet fall into two major categories: streaming and long polling.
In an application using streaming Comet, the browser opens a single persistent connection to the server for all Comet events, which is handled incrementally on the browser side. Each time the server sends a new event, the browser interprets it, but neither side closes the connection. Specific techniques for accomplishing streaming Comet include the following.
A basic technique for dynamic web application is to use a hidden IFrame HTML element (an inline frame, which allows a website to embed one HTML document inside another). This invisible IFrame is sent as a chunked block, which implicitly declares it as infinitely long (sometimes called “forever frame”). As events occur, the iframe is gradually filled with
script tag is executed as it is received.
One benefit of the IFrame method is that it works in every common browser. Two downsides of this technique are the lack of a reliable error handling method, and the impossibility of tracking the state of the request calling process.
The XMLHttpRequest (XHR) object, the main tool used by Ajax applications for browser–server communication, can also be pressed into service for server–browser Comet messaging, in a few different ways.
In 1995, Netscape Navigator added a feature called “server push”, which allowed servers to send new versions of an image or HTML page to that browser, as part of a multipart HTTP response (see History section, below), using the content type
multipart/x-mixed-replace. Since 2004, Gecko-based browsers such as Firefox accept multipart responses to XHR, which can therefore be used as a streaming Comet transport. On the server side, each message is encoded as a separate portion of the multipart response, and on the client, the callback function provided to the XHR
onreadystatechange function will be called as each message arrives. This functionality is only included in Gecko-based browsers, though there is discussion of adding it to Webkit.
onreadystatechange callback each time it receives new data.
Ajax with long polling
None of the above streaming transports works across all modern browsers without causing negative side-effects in any—forcing Comet developers to implement several complex streaming transports, switching between them depending on the browser. Consequently many Comet applications instead opt for long polling, which is easier to implement on the browser side, and works, at minimum, in every browser that supports XHR. As the name suggests, long polling requires the client to poll the server for an event (or set of events). The browser makes an Ajax-style request to the server, which is kept open until the server has new data to send to the browser, which is sent to the browser in a complete response. The browser initiates a new long polling request in order to obtain subsequent events.
Specific technologies for accomplishing long-polling include the following.
XMLHttpRequest long polling
Script tag long polling
While any Comet transport can be made to work across subdomains, none of the above transports can be used across different second-level domains (SLDs), due to browser security policies designed to prevent cross-site scripting attacks. That is, if the main web page is served from one SLD, and the Comet server is located at another SLD, Comet events cannot be used to modify the HTML and DOM of the main page, using those transports. This problem can be side-stepped by creating a proxy server in front of one or both sources, making them appear to originate from the same domain. However, this is often undesirable for complexity or performance reasons.
Unlike IFrames or XMLHttpRequest objects,
A long-polling Comet transport can be created by dynamically creating
Early Java applets
The ability to embed Java applets into browsers (starting with Netscape 2.0 in March 1996) made real-time communications possible, using a raw TCP socket to communicate between the browser and the server. This socket can remain open as long as the browser is at the document hosting the applet. Event notifications can be sent in any format — text or binary — and decoded by the applet.
First Comet applications
In March 2006, software engineer Alex Russell coined the term Comet in a post on his personal blog. The new term was a play on Ajax (Ajax and Comet both being household cleaners, common in the USA). This umbrella term for previously existing concepts attracted some enthusiasts, that since then advocate its use in web-related technology conferences and websites.
Browser-native technologies are inherent in the term Comet. Attempts to improve non-polling HTTP communication have come from multiple sides:
- The HTML 5 draft specification produced by the Web Hypertext Application Technology Working Group (WHATWG) specifies so called server-sent events, it offers a new HTML element,
event-sourceand a new data format called DOM event stream. Experimental implementation of this feature was introduced in Opera 9.
- The HTML 5 Web Sockets API working draft specifies a method for creating a persistent connection with a server and receiving messages via an
- The BOSH protocol by the XMPP standards foundation, usabe elsewhere. It emulates a bidirectional stream between browser and server by using two synchronous HTTP connections.
- The JSONRequest object, proposed by Douglas Crockford, would be an alternative to the XHR object.
- Use of plugins, such as Java applets or the proprietary Adobe Flash (Java BlazeDS is a server plugin which streams events to Flash applications). These have the advantage of working identically across all browsers with the appropriate plugin installed and need not rely on HTTP connections.
- ↑ Egloff, Andreas. "Ajax Push (a.k.a. Comet) with Java Business Integration (JBI)" JavaOne 2007, San Francisco, California (2007-05-05). Retrieved on 2008-06-10.
- ↑ 2.0 2.1 "Ajax Push" (in English) (html). ICEfaces.org. http://www.icefaces.org/main/product/ajaxpush.iface. Retrieved 2008-07-21.
- ↑ Crane, Dave; McCarthy, Phil (July 2008) (in English). Comet and Reverse Ajax: The Next Generation Ajax 2.0. Apress. ISBN 1590599985.
- ↑ 4.0 4.1 Mahemoff, Michael (June 2006). "Web Remoting" (in English). Ajax Design Patterns. O'Reilly Media. pp. 19; 85. ISBN 0596101805.
- ↑ Double, Chris (2005-11-05). "More on Ajax and server push". Different ways of doing server push. http://www.bluishcoder.co.nz/2005/11/more-on-ajax-and-server-push.html. Retrieved 2008-05-05.
- ↑ Nesbitt, Bryce (2005-11-01). "The Slow Load Technique/Reverse AJAX". Simulating Server Push in a Standard Web Browser. http://www.obviously.com/tech_tips/slow_load_technique. Retrieved 2008-05-05.
- ↑ HTTP 1.1 specification, section 8.1.4. W3C. Retrieved 30 November 2007
- ↑ 8.0 8.1 Holdener III, Anthony T. (January 2008). "Page Layout with Frames that Aren't". Ajax: The Definitive Guide. O'Reilly Media. p. 320. ISBN 0596528388.
- ↑ Johnny Stenback, et al. (March–April 2004). “Bug 237319 – Add support for server push using
multipart/x-mixed-replacewith XMLHttpRequest”. Mozilla bug tracking. Retrieved 29 November 2007. Also see:
Alex Russell (6 August 2005). “Toward server-sent data w/o iframes”. Alex Russell’s blog. Retrieved 29 November 2007.
- ↑ Rob Butler, et al. (June 2006). “Bug 14392: Add support for
multipart/x-mixed-replaceto XMLHttpRequest”. Webkit bug tracking. Retrieved 29 November 2007.
- ↑ http://web.archive.org/web/19961115203505/www27.netscape.com/comprod/products/navigator/version_2.0/index.html Netscape.com from 1996 (via Archive.org)
- ↑ http://java.sun.com/j2se/1.4.2/docs/api/java/net/Socket.html
- ↑ Alex Russell (3 March 2006). “Comet: Low Latency Data for the Browser”. Alex Russell’s blog. Retrieved 29 November 2007.
- ↑ K. Taft, Darryl (2006-05-12). "Microsoft Scrubs Comet from AJAX Tool Set" (html). eWEEK.com. http://www.eweek.com/c/a/Application-Development/Microsoft-Scrubs-Comet-from-AJAX-Tool-Set/. Retrieved 2008-07-21.
- ↑ Orbited: Enabling Comet for the Masses: OSCON 2008 - O'Reilly Conferences, July 21 - 25, 2008, Portland, Oregon
- ↑ Enterprise Comet & Web 2.0 Live Presentation
- ↑ Dion Almaer (29 September 2005). “Jotspot Live: Live, group note-taking” (interview with Abe Fettig). Ajaxian. Retrieved 15 December 2007.
Matt Marshall (15 December 2006). “Renkoo launches event service — in time to schedule holiday cocktails”. Venture Beat. Retrieved 15 December 2007.
- ↑ Clint Boulton (27 December 2005). “Startups Board the AJAX Bandwagon”. DevX News. Retrieved 18 February 2008.
- ↑ Ian Hickson, ed (2007-10-27). "6.2 Server-sent DOM events". HTML 5 - Call For Comments. WHATWG. http://www.whatwg.org/specs/web-apps/2007-10-26/multipage/section-server-sent-events.html#server-sent-events. Retrieved 2008-10-07.
- ↑ Bersvendsen, Arve (2006-09-01). "Event Streaming to Web Browsers". Opera Software. http://labs.opera.com/news/2006/09/01/. Retrieved 2009-06-01.
- ↑ Hickson, Ian (2009-04-23). "The Web Sockets API". w3c. http://www.w3.org/TR/websockets/. Retrieved 2009-07-21.
- ↑ Alex Russell, et al. (2007). "Bayeux Protocol - Bayeux 1.0draft1.". Dojo Foundation. http://svn.cometd.org/trunk/bayeux/bayeux.html. Retrieved 2007-12-14.
- ↑ Crockford, Douglas (2006-04-17). "JSONRequest Duplex". An alternative to XMLHttpRequest for long lasting server initiated push of data. http://www.json.org/JSONRequest.html. Retrieved 2008-05-05.
- Comet Daily – a website dedicated to articles on Comet techniques
- HTTP Streaming at Ajax Patternses:Comet