APE – An Introduction

APE (AJAX Push Engine) is basically a daemon which acts as a proxy between your client and the HTTPD. It allows thousands of users to exchange real time information through your existing web browser, no reloading and no plug-ins – a web developers dream.

From the APE website:

The first and most central part of APE is our epoll-driven HTTP server entirely written in C, which provides patterns such as XHR long-polling(cross browser), forever frame and many more. The server can be extended using modules, which can be written in both C and Server-Side JavaScript (pending).

The second part of APE is the Javascript Framework based on MooTools that deals with the APE protocol. We’ve put a lot of effort into making iteasy to “hook” into this framework. This enables our users to decide what Javascript framework they want to develop in, regardless of the choice we’ve made.

You can think of APE as reverse AJAX (much like Comet). Traditionally clients request information from the server and the server sends this information to the client for processing. APE can send information direct to clients’ browser, without the need of requesting it, resulting in less bandwidth and lower latency. You can read more upon the technologies behind APE here.

Sounds good? Great, let’s get started! You’ll need a Linux box (Windows not yet supported) with Apache installed and configured, GNU Make, GCC 3.4 and glibc. You’ll also need GIT to download the APE package. Optionally, install PHP and MySQL.

  1. Install the above packages with your distrubtions package manager. If you’re using Arch Linux you can simply do:
    pacman -Sy apache php mysql phpmyadmin glibc make gcc git
  2. Download the APE Server and APE JSF (JavaScript Framework) via GIT:
    git clone git://github.com/APE-Project/APE_Server.git
    git clone git://github.com/APE-Project/APE_JSF.git
    cd APE_Server

    This will create two directories, APE_Server and APE_JSF.

  3. Let’s compile APE and it’s modules:
    make && make install
    cd modules
    make

    Easy, huh?

  4. Edit ape.conf in bin/ – I just changed the user / group and daemon options. My ape.conf looks like:
    uid {
            # "aped" switch to this user/group if it run as root
            user = http
            group = http
    }
    
    Server {
            port = 6969
            daemon = yes
            ip_listen = 0.0.0.0
            ip_local = 127.0.0.1
            domain = ape-test.local
            rlimit_nofile = 65536
    }

    If your testing this over the Internet (i.e dedicated server) change the ip_listen and ip_local variables respectively.

  5. Configure Apache by loading mod_proxy, mod_proxy_http and mod_rewrite. These come with the Apache package in Arch Linux, but you may have to download them separately for your distro:
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    LoadModule rewrite_module modules/mod_rewrite.so

    Change your Listen and ServerName vars:

    Listen 192.168.10.151:80 #your local/external IP:port
    ServerName ape.ape-test.local:80 #ape.yourdomain.com:80

    You may need to add this to the bottom of your config (or proxy.conf):

    ProxyRequests On
    
            Order deny,allow
            Deny from all
            Allow from 192.168.10.151
  6. Update your DNS. If your testing APE locally just add these to /etc/hosts
    192.168.10.151  ape.ape-test.local      ape #your local/external IP
    127.0.0.1       ape.ape-test.local      ape
    127.0.0.1 0.ape.ape-test.local
    127.0.0.1 1.ape.ape-test.local
    127.0.0.1 2.ape.ape-test.local
    127.0.0.1 3.ape.ape-test.local

    if your testing over the Internet make sure you add the appropriate A records for your domains

  7. Setting up the directory structure and files. cd into the APE_JSF directory we downloaded from GIT and move all the files/folders within there to your WWW folder (Apaches DocumentRoot).
    Edit the file Demos/config.js. Mine looks like:

    APE.Config.baseUrl = 'http://ape.ape-test.local/Source'; //APE JSF
    APE.Config.domain = 'ape-test.local'; //Your domain, must be the same than the domain in aped.conf of your server
    APE.Config.server = 'ape.ape-test.local'; //APE server URL
  8. Starting and testing APE.
    cd /path/to/your/aped
    ./aped

    Open the following URL: http://0.ape.ape-test.com/?script&it_works&anticache (change if differant) and view the source, if you see

    document.domain="ape-test.local"

    it works!

Congratulations, you now have a full working APE server. You can try out the demos in the Demos\ directory and be amazed! My next post will be on using jQuery with the APE JavaScript Framework – stay tuned :)

  • Share/Bookmark

Related posts:

  1. Using jQuery With APE
  2. Diving into APE modules and the JSF – creating topics for channels
  3. Using jQuery with APE – an OOP approach with the DUI
  4. EsenAPE – send and receive SMS in real time using APE, jQuery, PHP and libape_controller
  5. Using jQuery With APE – change the background-color with PHP

2 Responses to “APE – An Introduction”

  1. Konstantin Mirin  on June 4th, 2009

    Cool thing. Will give it a try nearest time when I have a break between projects.
    Thanks for sharing!

    Reply

  2. Using jQuery With APE | Paul's Blog  on June 8th, 2009

    [...] going to test jQuery by making a simple demo using APE (see my setup guide here). Users will be able to change the background color of the document, this will then be sent to APE [...]

    Reply


Leave a Reply