Friday, January 6, 2012

Install XMPP Jabber chat message server on FreeBSD

Install XMPP Jabber chat message server on FreeBSD

XMPP server (also called Jabber server):
- ejabberd http://www.ejabberd.im/ // great!!!
- OpenFire
- jabber 1.x
- jabberd 2.x

XMPP Library:
- strophe http://strophe.im/ // great!!!

XMPP client (also called Jabber client):
- sparkweb
- oneteam http://oneteam.im/
- Candy http://amiadogroup.github.com/candy/ // great!!!
- jaxl https://github.com/abhinavsingh/JAXL
- punjab https://github.com/twonds/punjab // seems good? try it out.

Install ejabberd:
# cd /usr/ports/net-im/ejabberd ; make install

Before we configure ejabberd let's also create a certificate for encrypted connections that we'll use later - this requires OpenSSL to be installed, if you need help with that look here: (Link FOR OPENSSL article)
just type:

# openssl req -new -x509 -nodes -out /root/ejabberd.pem -keyout /root/ejabberd.pem -days 3650

# cd /usr/local/etc/ejabberd

# vi ejabberd.cfg

Go to line 91:
{hosts, ["localhost"]}.

Change it to your domain, in my case:
{hosts, ["jabber.local"]}.

Go to lines 120-123:
{access, c2s},
{shaper, c2s_shaper},
{max_stanza_size, 65536}
]},

change this part to:
{access, c2s},
{shaper, c2s_shaper},
starttls,{certfile,"/root/ejabberd.pem"},
starttls_required,
{max_stanza_size, 65536}
]},

Now go to line 435:
{access, register [{allow, all}]}.

Change it to:
{access, register, [{deny all}]}

What this setting changes is in-band registration - in other words now allowing the clients to register users themselves - the admin has to do it for them

# /usr/local/sbin/ejabberdctl start

To check if the server is running do:
# /usr/local/sbin/ejabberdctl status

Run ejabberd control and add a user - do a:
# /usr/local/sbin/ejabberdctl register YOUR_ADMIN_NAME jabber.local YOUR_ADMIN_PASSWORD

To check the registered users do:
/usr/local/sbin/ejabberdctl registered_users jabber.local

echo 'ejabberd_enable="YES"' >> /etc/rc.conf

If you have a firewall, make sure you open those ports:

5222 for XMPP client connections (c2s = client to server)
5269 for XMPP server connections (s2s = server to server). If you want that users in your server NOT be able to chat with users of other servers, you can close the port 5269.
5280 for HTTP client connections, including HTTP-Bind and WebAdmin. Needed for http_bind in Strophe.js

http://jabber.local:5280/admin

nginx.conf

server {
listen 80;
server_name jabber.local;

# This regexp did not work for me.
# location ~ ^/http-bind/ {
location /http-bind {
proxy_pass http://jabber.local:5280;
}

location / {
# This is where you place your strophejs sample.
root /www/strophejs-1.0.2;
}
}

# the above will serve 2 uri
http://jabber.local/examples/echobot.html
http://jabber.local/http-bind

Modify echobot.js line 1

var BOSH_SERVICE = 'http://jabber.local/http-bind';

Open http://jabber.local/examples/echobot.html and type:

JID: admin@jabber.local
Password: YOUR_ADMIN_PASSWORD

# It will show message like this.
Strophe is connecting.
Strophe is connected.
ECHOBOT: Send a message to admin@jabber.local/17607732121320955177312807 to talk to me.

Send a message(Chat)

From your Psi, right click , select "Open Chat To" , then pick the resource (eg: 17607732121320955177312807)
When you send the message, it will echo what you sent to the browser like this

Jabber Clients:
Use pidgin or psi

JWChat - is a full featured, web-based Jabber client. Written using AJAX technology it relies on JavaScript and HTML at the client-side only

http://blog.jwchat.org/jwchat/

Reference:
http://gala4th.blogspot.com/2011/12/install-xmpp-jabber-chat-message-server.html
http://my.opera.com/weirdbricks/blog/ejabberd-on-freebsd-8-1
http://groups.drupal.org/node/59163
http://metajack.wordpress.com/2008/07/02/xmpp-is-better-with-bosh/
Professional XMPP Programming with JavaScript and jQuery

1 comment:

Rob Lightbody said...

Hello. I've been tasked to find and Ejabbard consultant to do a code review for my company.
I found your blog and thought I'd ask if you are available, or if you could recommend someone.
The review should take 2 weeks or less.
Let me know what you think.
Thank you,
Rob