Chat Server Implementation using Jabber and IM Clients Installation
What is jabber ?
Jabber
1. Rapid and indistinct speech
2. To talk in a noisy, excited, or declamatory manner
3. A streaming XML technology mainly used for instant messaging
Jabber is best known as "the Linux of instant messaging" -- an open, secure, ad-free alternative to consumer IM services like AIM, ICQ, MSN, and Yahoo (see the IM quickstart). Under the hood, Jabber is a set of streaming XML protocols and technologies that enable any two entities on the Internet to exchange messages, presence, and other structured information in close to real time. Jabber technologies offer several key advantages:
Open -- the Jabber protocols are free, open, public, and easily understandable; in addition, multiple implementations exist for clients, servers, components, and code libraries.
Standard -- the Internet Engineering Task Force (IETF) has formalized the core XML streaming protocols as an approved instant messaging and presence technology under the name of XMPP, and the XMPP specifications have been published as RFC 3920 and RFC 3921.
Proven -- the first Jabber technologies were developed by Jeremie Miller in 1998 and are now quite stable; hundreds of developers are working on Jabber technologies, there are tens of thousands of Jabber servers running on the Internet today, and millions of people use Jabber for IM.
Decentralized -- the architecture of the Jabber network is similar to email; as a result, anyone can run their own Jabber server, enabling individuals and organizations to take control of their IM experience.
Secure -- any Jabber server may be isolated from the public Jabber network (e.g., on a company intranet), and robust security using SASL and TLS has been built into the core XMPP specifications.
Extensible -- using the power of XML namespaces, anyone can build custom functionality on top of the core protocols; to maintain interoperability, common extensions are managed by the Jabber Software Foundation.
Flexible -- Jabber applications beyond IM include network management, content syndication, collaboration tools, file sharing, gaming, and remote systems monitoring.
Diverse -- a wide range of companies and open-source projects use the Jabber protocols to build and deploy real-time applications and services; you will never get "locked in" when you use Jabber technologies.
Download Jabber
Server
http://www.jabber.org/software/servers.shtml
Client
http://www.jabber.org/software/clients.shtml
Jabber Documentation
http://www.jabber.org/user/userguide/
Jabber FAQ
http://www.jabber.org/user/userfaq.shtml
Installing Jabber in Debian
#apt-get install jabber
This will download and install jabber, jabber-common and any other packages your system might need. The server will be started automatically at this point, so we need to stop it and update the configuration to work with your host. To stop the server run
# /etc/init.d/jabber stop
Now we can look at the configuration files inside the directory /etc/jabber. The main thing that we need to setup is the hostname directive. The server itself is primarily configured via the XML file /etc/jabber/jabber.xml, but as a convience the startup script of the Debian package will make use of the file jabber.cfg as well, and this is where we'll set the name up. In a small office where you have your own DNS system it is useful to setup a hostname to refer to the system, this allows you to move machines without having to change any clients. We've used chat.my.company before for this purpse. In this case We are just using the hostname of the current machine. So edit the file /etc/jabber/jabber.cfg to have your hostname
JABBER_HOSTNAME (which is then passed to jabberd in the -h switch)
JABBER_HOSTNAME=chatserver.my.flat
Now we can start the server up
# /etc/init.d/jabber start
Starting jabberd: jabberd.
Connecting to the server involves downloading and installing a chat client.Client is gabber for Linux, and Exodus for Windows. Other clients exist packaged for Debian including PSI. To install gabber, on a client machine, run
#apt-get install gabber
Then once it's installed you will be shown a connection dialog. This has space for a username, a password, and a server name. Enter the username and password you wish to use and the name of the server you already setup. (In my case thats undecided.my.flat). Once you click the connect button you will see the following error message
Gabber could not log you in.
Would you like Gabber to try to create a new
account on the selected Jabber server?
Click 'Yes' and your account will be created. You will then see the main contact window which should show that you have received a new message from the server saying 'Welcome'. If you now move to another machine you can repeat the process to add another user. Finally you can add the users to each others contact list, called a roster in Jabber-speak. Click on the Actions menu and select Add Contact. Then choose Add this JabberID. Type in the ID of the user you wish to add in, remembering to add the hostname. For example
[email protected]
All Jabber contacts have the form [email protected] - just like an email address, even though it isnt! Once the other person logs in and approves the addition you will be able to chat to them! The roster lists are all maintained upon the server side, in a directory beneath /var/lib/jabber named after the servers hostname. If you examine one of the ones you've created already you will see there is a section at the start for the username and password and some global options and then at the end there is a section at the end for the contacts. With a bit of scripting you can generate these files for all your users yourself and add each other to their groups.
Jabber Transports (MSN, Yahoo, ICQ etc)
Jabber Clients Installation
#aptitude search jabber
will show you what is available. I'm going to go through jabber-msn (MSN), jabber-jit (ICQ) and jabber-yahoo (Yahoo).
Let's install them
#aptitude install jabber-jit jabber-msn jabber-yahoo
Now - we need to configure and enable them.
Hostnames
For the transports to work - you need to set hostnames - and - if you are running the server non-locally then you need to have resolvable hostnames.
We chose the following scheme:
jabber.mydomain.tld
msn.jabber.mydomain.tld
conf.msn.jabber.mydomain.tld
icq.jabber.mydomain.tld
yahoo.jabber.mydomain.tld
All of these are CNAMES to the same machine. I am not sure if they require to have different hostnames - but the examples seem to suggest this.
Configuration
You need to configure so that the jabber server knows about the transports and also so that the transports will announce themselves to the jabber client.
In the debian package config /etc/jabber/jabber.xml find the section.
Here we add the browse config (these are taken from the /usr/share/doc/jabber-*/README.Debian files - the only change was the hostname in each case).
<service type="yahoo" jid="yahoo.jabber.mydomain.tld" name="Yahoo! Transport">
<ns>jabber:iq:gateway</ns>
<ns>jabber:iq:register</ns>
</service>
<service type="msn" jid="msn.jabber.mydomain.tld" name="MSN Link">
<ns>jabber:iq:gateway</ns>
<ns>jabber:iq:register</ns>
</service>
<service type="icq" jid="icq.jabber.mydomain.tld" name="ICQ Link">
<ns>jabber:iq:gateway</ns>
<ns>jabber:iq:register</ns>
<ns>jabber:iq:search</ns>
</service>
Next we need to add the actual services - add the following new service sections (again taken from /usr/share/doc)
<service id="msn">
<host>msn.jabber.mydomain.tld</host>
<host>conf.msn.jabber.mydomain.tld</host>
<accept>
<ip>your_ip</ip>
<port>5557</port>
<secret>asecret</secret>
<timeout>30</timeout>
</accept>
</service>
<service id="yahoo.jabber.mydomain.tld">
<accept>
<ip>your_ip</ip>
<port>9001</port>
<secret>asecret</secret>
</accept>
</service>
<service id="icq">
<host>icq.jabber.mydomain.tld</host>
<host>sms.icq.jabber.mydomain.tld</host>
<accept>
<ip>your_ip</ip>
<port>5555</port>
<secret>asecret</secret>
<timeout>30</timeout>
</accept>
</service>
Finally we need to edit the transport config files (/etc/jabber/jabber-*.xml). Here you need to make sure that the following is done
make sure that the is the same as set in the main config
Enabling
In /etc/default/ you will find jabber-* files. The value ENABLED must be changed from 0 to 1
Using
Given that you have a jabber account on the jabber server we can now add buddies via the transports.
You need to use your jabber client to run services discovery on the server. That should show the transports that are available (amongst any other allowed services).
Choose a transport and then register. You can then fill out your account details for that chat system.
It should then find any buddies (most of these IMs have server stored buddy lists) - but - when manually adding buddies the syntax is
ICQ user has an ID of UIN: [email protected]
MSN: user has an ID of [email protected]: user%[email protected]
Yahoo: user has an ID of YahooID: [email protected]