Get updates

Scott First Steps to Comet: Orbited in PHP

I’ve recently become interested in Comet, as a web technology, and Orbited, as a Comet server. For anyone else starting down this path, I thought I’d write up the summary of this weekend’s quick foray into event-driven server-sent-messaging goodness.

My goal was simple: get a basic Comet equivalent of “hello world” running on my local box (which is running openSUSE Linux, with Apache, but Orbited claims to run on almost anything).

First I downloaded the Orbited daemon. Following their installation tutorial was fairly easy, though I did have to get Python’s dev package installed (also easy enough, from YaST).

Second I downloaded their PHP client for Orbited, following along in the PHP Orbited tutorial. I also downloaded their PHP version of the cherrychat demo, and put those files plus the PHP client file in Apache’s web root.

Next I started up the Orbited server daemon:
> orbited

Pretty easy huh?

At that point I was ready to test it out. Opening in one window and http://localhost:8000/orbit.html in another (even easier with Opera’s horizontal window tiling) got me to the initial page. Type a name in one and click nickname… and nothing? No JavaScript error either.

Turns out that the chat.js file had a small set of errors. The Ajax request URLs to join the chat and to send messages were malformed, multiple question marks where they should be ampersands after the initial ? query character. I found this out the hard way, after poking around in logs and other areas to discover where the problem was, but I could have fixed it quickly if I had read this discussion instead.

After fixing chat.js everything worked nicely. My two windows talked to each other, receiving messages immediately in one when sent from the other. The implications for web applications (including games!) are exciting.

Finally, note that using two different addresses does seem important, as a test (out of curiosity) of two tabs on the same address seemed to get Orbited stuck in a loop.

While Orbited, and Comet in general, may be a little raw in its current state, I look forward to further developments in this area and I’m already thinking of tons ways in which applications can benefit from server-sent data updates. Pretty exciting time to be a web developer if you ask me.

One Response to “First Steps to Comet: Orbited in PHP”

  1. adam Says:

    Hi, I was wondering about the scalability of this method; I mean can it handle 1k, 10k, 100k of parallel connexions?

Leave a Reply