Hello Comet: Part 1
Comet is a web application model that enables web servers to send data to the client without having to explicitly request it. Comet is an umbrella term for multiple techniques for achieving this interaction. All these methods rely on features included by default in browsers, such as JavaScript. This approach allows developers create event-driven web applications without any non-default browser plugins.
In practice, Comet applications typically use Ajax with long polling to detect new information on the server. This concept is also known as Ajax Push, Reverse Ajax, HTTP streaming, etc.
In this article we will use Lightstreamer – web server for pushing live data to Rich Internet Applications. Lightstreamer can stream real-time data to any client – simple HTML form, Flash/Flex/Silverlight or even iPhone application. In first part of the article, we will setup and configure Lightstreamer for our demo. We will use Lightstream Moderato Free Edition which is quite adequate for our test application.
I installed Lightstream server under Ubuntu 8.04 LTS Server edition. Windows distribution is also available.
- First, download Free version from Lightstreamer website (registration required).
- Make sure you have a JDK installed on your system. To install JDK for Ubuntu just type in console
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
- Extract the archive
tar xvfz Lightstreamer_Moderato.tar.gz
- In order to use Lightstreamer Moderato Edition, you need a valid Free License. To get your license fill out the following form (you’ll be asked to provide your machine MAC address). Shortly, you will receive an email with your ClientID and license file attached. Copy your license file to Lightstreamer/conf directory.
- Now you need to configure your license. Open “lightstreamer_conf.xml” file, located under the Lightstreamer/conf directory. Place your ClientID in the <client_id> element and the name of your license file in the <license_path> element. By default installation uses TCP ports 8080, 9999 and 6666. If any of these ports are already in use on your system, change them by editing the following elements: <port>, <jmxmp_connector_port> and <html_adaptor_port>
- Open Lightstreamer/bin/unix-like/LS.sh and set LS_HOME and JAVA_HOME according to your environment.
- Launch the server. Go to the Lightstreamer/bin/unix-like/ and execute
sh start.sh
Now, you can point your browser to http://localhost:8080. You should see a welcome page containing the links to some pre-installed demos.
In next part of the article we will create very basic application to try Lightstreamer in action.
Hello Comet: Part 1Tagged as ajax, comet, lightstreamer
Leave a Reply