I had a previous APE installation that was on an CentOS box
(undocumented install), which I'm trying to script for EC2 on Ubuntu.
I can get a client to connect successfully, but it does not receive
messages.  This is probably because the Tools/Check fails with
"Exception 18", which is:

Running test : Init
Running test : Loading Client
Running test : Loading config
Config values are :
identifier : ape
init : true
frequency : 0
scripts :
http://local.ape-project.org/APE_JSF/Source/mootools-core.js,http://local.ape-project.org/APE_JSF/Source/Core/APE.js,http://local.ape-project.org/APE_JSF/Source/Core/Events.js,http://local.ape-project.org/APE_JSF/Source/Core/Core.js,http://local.ape-project.org/APE_JSF/Source/Pipe/Pipe.js,http://local.ape-project.org/APE_JSF/Source/Pipe/PipeProxy.js,http://local.ape-project.org/APE_JSF/Source/Pipe/PipeMulti.js,http://local.ape-project.org/APE_JSF/Source/Pipe/PipeSingle.js,http://local.ape-project.org/APE_JSF/Source/Request/Request.js,http://local.ape-project.org/APE_JSF/Source/Request/Request.Stack.js,http://local.ape-project.org/APE_JSF/Source/Request/Request.CycledStack.js,http://local.ape-project.org/APE_JSF/Source/Transport/Transport.longPolling.js,http://local.ape-project.org/APE_JSF/Source/Transport/Transport.SSE.js,http://local.ape-project.org/APE_JSF/Source/Transport/Transport.XHRStreaming.js,http://local.ape-project.org/APE_JSF/Source/Transport/Transport.JSONP.js,http://local.ape-project.org/APE_JSF/Source/Transport/Transport.WebSocket.js,http://local.ape-project.org/APE_JSF/Source/Core/Utility.js,http://local.ape-project.org/APE_JSF/Source/Core/JSON.js
baseUrl : http://local.ape-project.org/APE_JSF
domain : ape-project.org
server : ape.local.ape-project.org:6969
Running test : Setting document.domain
Can't set document.domain please check APE.Config.domain value it
should be ape.demandresults.com

I'm trying to publish messages on http://ape.demandresults.com:6969
from a Java client (not javascript), and this DID work previously.

I've tried many configurations, but what below is the current, semi-
working setup.  Please help!!

Setup script:

#!/bin/bash
# Run in sudo

chmod 777 /etc/apt/sources.list
echo -e "deb http://us.archive.ubuntu.com/ubuntu/ natty universe" >> /
etc/apt/sources.list
echo -e "deb-src http://us.archive.ubuntu.com/ubuntu/ natty universe"
>> /etc/apt/sources.list
echo -e "deb http://us.archive.ubuntu.com/ubuntu/ natty-updates
universe" >> /etc/apt/sources.list
echo -e "deb-src http://us.archive.ubuntu.com/ubuntu/ natty-updates
universe" >> /etc/apt/sources.list

echo -e "deb http://us.archive.ubuntu.com/ubuntu/ natty multiverse"
>> /etc/apt/sources.list
echo -e "deb-src http://us.archive.ubuntu.com/ubuntu/ natty
multiverse" >> /etc/apt/sources.list
echo -e "deb http://us.archive.ubuntu.com/ubuntu/ natty-updates
multiverse" >> /etc/apt/sources.list
echo -e "deb-src http://us.archive.ubuntu.com/ubuntu/ natty-updates
multiverse" >> /etc/apt/sources.list

# Update after new sources list
apt-get update

# Install necessary packages
aptitude install -y zip apache2 stunnel4 gcc ec2-api-tools ec2-ami-
tools ntp libssl-dev git-core build-essential subversion git git-svn
python unzip libgtk2.0-0

# Upgrade all the packages
apt-get upgrade -y

# Configure date
chmod 777 /etc/cron.daily
echo -e "ntpdate ntp.ubuntu.com" > /etc/cron.daily/ntpdate

# Update ulimits
cat >> /etc/security/limits.conf <<EOF

*                soft    nofile     131072
*                hard    nofile     131072
root     soft    nofile     131072
root     hard    nofile     131072

EOF

# Configure memory usage
sysctl -w net.core.rmem_max=4194304
sysctl -w net.core.wmem_max=4194304

# APE
git clone https://github.com/APE-Project/APE_Server.git
cd /home/ubuntu/APE_Server
./build.sh

# Congifure APE
sed -i "s/daemon = no/daemon = yes/g" /home/ubuntu/APE_Server/bin/
ape.conf
sed -i "s/include(\"examples\/nickname.js\")/\/\/include(\"examples\/
nickname.js\")/g" /home/ubuntu/APE_Server/scripts/main.ape.js
sed -i "s/password = testpasswd/password = somepassword/g" /home/
ubuntu/APE_Server/modules/conf/inlinepush.conf

# Start APE
cd /home/ubuntu/APE_Server/bin
./aped

# APE JSF
cd /var/www
git clone https://github.com/APE-Project/APE_JSF.git

# Download config
s3cmd get s3://demandresults-setup/apeClientJS.js /var/www/APE_JSF/
Build/yuiCompressor/ --force
sudo chmod 755 /var/www/APE_JSF/Build/yuiCompressor/apeClientJS.js

cd /var/www/APE_JSF
sudo mv * ..
rm -r /var/www/APE_JSF

# Create symlink
ln -sf /var/www/Build/yuiCompressor/apeClientJS.js /var/www/rt.js

# Edit APE_SERVER/bin/ape.conf

# Edit /etc/apache2/sites-available/default

service apache2 restart

rt.js:

var APE={Config:{identifier:"ape",init:true,frequency:0,scripts:
[]},Client:function(a){if(a)
{this.core=a}}};APE.Client.prototype.eventProxy=[];APE.Client.prototype.fireEvent=function(c,b,a)
{this.core.fireEvent(c,b,a)};APE.Client.prototype.addEvent=function(d,c,a)
{var e=c.bind(this),b=this;if(this.core==undefined)
{this.eventProxy.push([d,c,a])}else{var
b=this.core.addEvent(d,e,a);this.core.$originalEvents[d]=this.core.
$originalEvents[d]||[];this.core.$originalEvents[d][c]=e}return
b};APE.Client.prototype.removeEvent=function(b,a){return
this.core.removeEvent(b,a)};APE.Client.prototype.onRaw=function(c,b,a)
{this.addEvent("raw_"+c.toLowerCase(),b,a)};APE.Client.prototype.onCmd=function(c,b,a)
{this.addEvent("cmd_"+c.toLowerCase(),b,a)};APE.Client.prototype.onError=function(c,b,a)
{this.addEvent("error_"+c,b,a)};APE.Client.prototype.cookie={};APE.Client.prototype.cookie.write=function(a,b)
{document.cookie=a+"="+encodeURIComponent(b)+";
domain="+document.domain};APE.Client.prototype.cookie.read=function(b)
{var e=b+"=";var a=document.cookie.split(";");for(var d=0;d<a.length;d+
+){var f=a[d];while(f.charAt(0)==" "){f=f.substring(1,f.length)}
if(f.indexOf(e)==0){return
decodeURIComponent(f.substring(e.length,f.length))}}return
null};APE.Client.prototype.load=function(config){config=config||
{};config.transport=config.transport||APE.Config.transport||
0;config.frequency=config.frequency||0;config.domain=config.domain||
APE.Config.domain||document.domain;config.scripts=config.scripts||
APE.Config.scripts;config.server=config.server||
APE.Config.server;config.secure=config.sercure||
APE.Config.secure;config.init=function(core){this.core=core;for(var
i=0;i<this.eventProxy.length;i++)
{this.addEvent.apply(this,this.eventProxy[i])}}.bind(this);if(config.transport!
=2){if(config.domain!="auto"){document.domain=config.domain}
if(config.domain=="auto"){document.domain=document.domain}}var
cookie=this.cookie.read("APE_Cookie");var tmp=eval("("+cookie
+")");if(tmp){config.frequency=tmp.frequency+1}
else{cookie='{"frequency":0}'}var reg=new RegExp('"frequency":
([ 
0-9]+)',"g");cookie=cookie.replace(reg,'"frequency":'+config.frequency);this.cookie.write("APE_Cookie",cookie);var
iframe=document.createElement("iframe");iframe.setAttribute("id","ape_"+config.identifier);iframe.style.display="none";iframe.style.position="absolute";iframe.style.left="-300px";iframe.style.top="-300px";document.body.insertBefore(iframe,document.body.childNodes[0]);var
initFn=function()
{iframe.contentWindow.APE.init(config)};if(iframe.addEventListener)
{iframe.addEventListener("load",initFn,false)}
else{if(iframe.attachEvent){iframe.attachEvent("onload",initFn)}}
if(config.transport==2){var doc=iframe.contentDocument;if(!doc)
{doc=iframe.contentWindow.document}doc.open();var
theHtml="<html><head>";for(var i=0;i<config.scripts.length;i++){theHtml
+='<script type="text/JavaScript" src="'+config.scripts[i]+'"><\/
script>'}theHtml+="</head><body></body></
html>";doc.write(theHtml);doc.close()}else{iframe.setAttribute("src",
(config.secure?"https":"http")+"://"+config.frequency+"."+config.server
+'/?[{"cmd":"script","params":{"domain":"'+document.domain
+'","scripts":["'+config.scripts.join('","')
+'"]}}]');if(navigator.product=="Gecko")
{iframe.contentWindow.location.href=iframe.getAttribute("src")}}};if(Function.prototype.bind==null)
{Function.prototype.bind=function(b,a){return
this.create({bind:b,"arguments":a})}}
if(Function.prototype.create==null)
{Function.prototype.create=function(b){var a=this;b=b||{};return
function(){var c=b.arguments||arguments;if(c&&!c.length){c=[c]}var
d=function(){return a.apply(b.bind||null,c)};return d()}}};
/***
 * APE JSF Setup
 */

var rtPipe;

/**
* Not in use
*/
function authInit (md5) {

}

function init(channel, callback, returnJSON) {
    var client = new APE.Client();
    client.load();
    client.addEvent('load', function() {
                        client.core.start();
    });

    client.addEvent('ready', function() {
                join(client , channel);
        client.onRaw('data', function(raw, pipe) {
                callback(raw.data);
        });
        });

        client.addEvent('uniPipeCreate', function(pipe, options){
                rtPipe = pipe;
        });

        return client;
}

function leave (client, pubid) {
        client.core.left(pubid);
}

function quit(client){
        client.core.quit();
}

function join (client, channel) {
    if (isArray(channel) == false) {
        channel = removeNonAlphas(channel);
        client.core.join(channel);
        } else {
        for (var i in channel) {
                channel[i] = removeNonAlphas(channel[i]);
        }
        client.core.join(channel);
    }
}

function removeNonAlphas(channel){
    channel = channel.replace(/[^a-zA-Z 0-9]+/g,'');
    return channel;
}

function isArray(obj) {
    if (obj.constructor.toString().indexOf("Array") == -1)
    return false;
    else
    return true;
}

APE.Config.baseUrl = 'http://ape.demandresults.com/'; //APE JSF
APE.Config.domain = 'ape.demandresults.com';
APE.Config.server = 'ape.demandresults.com:6969'; //APE server URL
APE.Config.transport = 2;  // 2 is JSONP

(function(){
        for (var i = 0; i < arguments.length; i++)
                APE.Config.scripts.push(APE.Config.baseUrl + '/Source/' +
arguments[i] + '.js');
})('mootools-core', 'Core/APE', 'Core/Events', 'Core/Core', 'Pipe/
Pipe', 'Pipe/PipeProxy', 'Pipe/PipeMulti', 'Pipe/PipeSingle', 'Request/
Request','Request/Request.Stack', 'Request/Request.CycledStack',
'Transport/Transport.longPolling','Transport/Transport.SSE',
'Transport/Transport.XHRStreaming', 'Transport/Transport.JSONP',
'Transport/Transport.WebSocket', 'Core/Utility', 'Core/JSON');

ape.conf:

uid {
        # "aped" switch to this user/group if it run as root
        user = daemon
        group = daemon
}


Server {
        port = 6969
        daemon = yes
       # Works with either EC2 internal IP or 0.0.0.0
        ip_listen = 0.0.0.0
        domain = ape.demandresults.com
        rlimit_nofile = 10000
        pid_file = /var/run/aped.pid
}

Log {
        debug = 1
        use_syslog = 0
        syslog_facility = local2
        logfile = ./ape.log
}

JSONP {
        eval_func = Ape.transport.read
        allowed = 2
}

Config {
        modules = ../modules/lib/
        modules_conf = ../modules/conf/
}

/etc/apache2/sites-available/default:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        # APE CONFIGURATION
        ServerAlias ape.demandresults.com
        ServerAlias *.ape.demandresults.com

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to