Strophe Preview: XMPP In JavaScript


Three years ago, we released libstrophe to the world. libstrophe is a cross-platform C library for writing XMPP clients. libstrophe exists because none of the C libraries at the time worked well on Windows platforms. A year or so later, I discovered the potential of XMPP on the Web and created a JavaScript version as a first step to a Web based Chesspark client. I never officially released strophe.js, but it is available under the GPL license for anyone who was brave enough to dig it out of the Chesspark JavaScript code. It’s time to make it official.

Some Features Of Strophe

Strophe has a lot of neat features.  Probably the most compelling is that it has been well tested for 2 years in all major browsers.  It catches many errors and includes optimizations that no other AJAX framework seems to.  It has been used by hundreds of thousands of people via the Chesspark site.

Strophe was developed in a climate where low latency is critical.  People do not enjoy waiting for game moves or clock updates, and so Strophe does its best to deliver excellent performance.

Strophe is very simple.  Not only is the API small and easy to understand, but there are numerous helpers in there to make life easy.  Strophe.Builder helps you build stanzas quickly.  For example:

$iq({type: 'get'})
    .c('query', {xmlns: Strophe.NS.ROSTER})

Will generate this XML stanza:

<iq type='get'>
<query xmlns='jabber:iq:roster'/>

Strophe In Action

If you’d like to see what is possible with Strophe, please check out the Chesspark Web client and the Speeqe demo site.

Take a Sneak Peek

I’m almost finished preparing Strophe 1.0 for release, which includes the original libstrophe C library, the strophe.js JavaScript library, and complete documentation for both.  I hope to make Strophe the best XMPP library around for native or web development.

Until it is released, you can can see a preview of the JavaScript version or read the API documentation.  This version was refactored and made more modular compared to the Chesspark version, and it hasn’t been fully tested yet.  It does however work great in my initial tests with a slightly modified version of the Chesspark Web client.

I’m very interested in any feedback the community has for Strophe.


12 Responses to “Strophe Preview: XMPP In JavaScript”

  1. Hi,

    congrats, it looks much cleaner than jsjac, my current tool.

    I’ll definitively work with it a bit.

    Best regards,

  2. 2 metajack

    @pedro: Thanks. I believe jsjac also includes a basic jabber client implementation, but Strophe is just the bits and pieces you’d need to write a client. I’ll be posting some tutorials and things soon.

  3. This looks very nice.

    As you may know, there are several (many?) half-baked comet implementations out there. Could you compare/contrast this verses a ‘pure comet’ solution (whatever that means :).

    I know you guys at Chesspark use Twisted a fair amount, could you go into more detail on how you connect the two (strophe twisted)? If that is in fact what you do.

    Anyways, I’m anxiously waiting on some tutorials, etc

  4. This post:
    answers the questions (and more!) I had in my previous comment.

    Please, if you have the time, post the Twisted BOSH client code, or other examples.
    Very cool stuff, thanks!

  5. 5 tofu

    The Twisted BOSH client code is punjab.

  6. 6 Brandon Jones

    I actually have a question regarding the nature of how exactly this would connect to a server, because I’m thinking of replacing our current means of Live Chat for our website. The way we do it now requires a server-side jabber application that gets run by the server based on a background call made when the user tries to connect, this program goes on to read a file system to check an XML file and update one too. But it’s more processor intensive than we’d like out of the web application, so we want to replace it.

    The only thing I’m really curious about is how to allow connection to a jabber server on our network, but not publicly exposed. It wouldn’t be as simple as specifying or anything like that, we would need to supply an IP address. I’m not entirely sure how this works, and whether or not supplying the IP address to your API would allow for a BOSH connection to the server or not. Further guidance on this would be much appreciated.

    Brandon Jones

  7. 7 metajack

    @Brandon: The Strophe code connects to a BOSH service, usually at the same domain. Depending on the BOSH service, you may or may not be allowed to use any internet accessible XMPP server. For instance, with Punjab, you can connect to anything. With the BOSH service that comes as part of many XMPP servers, you will be restricted to that specific server.

    You will always need to run a BOSH service somewhere for Strophe, but that service does not need to be heavyweight. For example, Punjab is quite lean on the CPU, which is what we wrote and use at Chesspark.

    As to how to connect to a private jabber server, just restrict the jabber server from accepting connections from anything but the bosh service, which is running somewhere locally. You can let the BOSH service handle dns resolution, even if the resolution is to an internal IP address. Just hardcode the domain when you call the Strophe.Connection.connect() function.

  8. 8 Favio


    first of all, thanks for providing Strophe to the community!

    I’ve been playing with the Strophe library found in the speeqe chat. I setup punjab as the INSTALL.txt said. However, I’m not getting any response (I’m looking at the firebug console). I’m using jabber14 as the server. Do you have to configure anything else in punjab to make it connect to the jabber server? or maybe I have to add punjab to the jabber server configuration? Pardon the noobness.

    Also, what would be the more appropriate place to post these kind of questions? 🙂

  9. Just for continuity, the above question is related to a problem that is already solved. I was having a simple DNS issue. I wasn’t aware that twistd generated a log file, and as soon as I realized that and read it, the situation was very clear to me.

  1. 1 The State Of JavaScript Documentation Tools « metajack
  2. 2 links for 2008-07-02 « dMitry Alexandrov
  3. 3 XMPP Is Better With BOSH « metajack

%d bloggers like this: