Keoko home about

Round III, now with BOSH.

After attempt 1 and attempt 2 trying to connect XIFF to ejabberd without applying any patch to ejabberd I finally tried with BOSH connection and IT WORKED!!!

Below are the steps I followed to test a chat example.

  1. install latest SVN XIFF version (Checked out revision 10959)
    export TEST_DIR=/tmp/xiffstep1
    mkdir -p $TEST_DIR/xiff
    cd  $TEST_DIR/xiff
    svn co http://svn.igniterealtime.org/svn/repos/xiff/trunk/src/org org
  2. install latest SVN ejabberd version (revision 1867)
    cd  $TEST_DIR
    svn co http://svn.process-one.net/ejabberd/trunk/ ejabberd_src
    cd $TEST_DIR/ejabberd_src/src
    ./configure --prefix=$TEST_DIR/ejabberd
    make
    sudo su
    make install
  3. install mod_http_bind in ejabberd and load module in ejabberd.cfg (see this article).
    cd $TEST_DIR/
    svn co http://svn.process-one.net/ejabberd-modules ejabberd_modules_src
    cd $TEST_DIR/ejabberd_modules_src/http_bind/trunk
    ./build.sh
    sudo su
    cp ebin/*.beam $TEST_DIR/ejabberd/lib/ejabberd/ebin/
    # load mod_http_bind in ejabberd.cfg: {mod_http_bind,[]},
    # add request_handler in ejabberd.cfg: {request_handlers, [{["http-bind"], mod_http_bind}]}
    cd $TEST_DIR/ejabberd/etc/ejabberd
    wget http://www.keoko.net/wp-content/uploads/2009/02/ejabberd.cfg
    
  4. setup ejabberd and create two users (sender, receiver).
    cd $TEST_DIR/ejabberd/sbin
    ./ejabberdctl start
    ./ejabberdctl register user1 localhost user1
    ./ejabberdctl register user2 localhost user2
  5. install nginx and configure it as reverse proxy to ejabberd
    sudo apt-get install nginx
    sudo vim /usr/local/nginx/conf/nginx.conf
    # add the following lines after location / block
            location /xmpp-httpbind {
                proxy_pass   http://localhost:5280/http-bind;
                break;
            }
    sudo killall nginx
    sudo /usr/local/nginx/sbin/nginx
    
  6. get chat example files: XIFFstep1BOSH.mxml and TestChatBosh.as (this example is based on this article).
    cd $TEST_DIR/xiff
    wget http://www.keoko.net/wp-content/uploads/2009/02/xiffstep1bosh.mxml
    wget http://www.keoko.net/wp-content/uploads/2009/02/testchatbosh.as
  7. create AS3 project "XIFFstep1BOSH" with eclipse + Flex Builder, import library XIFF and example file into the project and run the application.
    # run eclipse
    File > New > Flex Project -> Project Name: XIFFstep1Bosh
    Delete > XIFFstep1BOSH.mxml
    File > Import > General > File System > Next > From directory: $TEST_DIR/xiff
    Run > Run
  8. open another XMPP client (e.g. Psi) with user2.
  9. send message through the flash application in the browser window that has been opened.
  10. check the message has been received in the other XMPP client (user2).

Mickaël Rémond was right: XMPP works with flash out of the box ... with BOSH connections, not with XML socket connections.