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 http://127.0.0.1:8000/orbit.html 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?
    thanks

Leave a Reply


Fatal error: Uncaught Error: Call to undefined function show_subscription_checkbox() in /home/dmetro/3dmdesign.com/wp-content/themes/hex_columns/comments.php:90 Stack trace: #0 /home/dmetro/3dmdesign.com/wp-includes/comment-template.php(1472): require() #1 /home/dmetro/3dmdesign.com/wp-content/themes/hex_columns/single.php(65): comments_template() #2 /home/dmetro/3dmdesign.com/wp-includes/template-loader.php(74): include('/home/dmetro/3d...') #3 /home/dmetro/3dmdesign.com/wp-blog-header.php(19): require_once('/home/dmetro/3d...') #4 /home/dmetro/3dmdesign.com/index.php(17): require('/home/dmetro/3d...') #5 {main} thrown in /home/dmetro/3dmdesign.com/wp-content/themes/hex_columns/comments.php on line 90