WebReference.com - Part 2 of Chapter 3 from Programming Jabber, O'Reilly & Associates (3/3) | WebReference

WebReference.com - Part 2 of Chapter 3 from Programming Jabber, O'Reilly & Associates (3/3)

To page 1To page 2current page

Programming Jabber

Monitoring and Troubleshooting the Server

We've already seen a glimpse of the configuration relating to logging of messages in the previous section. As standard, the Jabber server configuration describes two types of logging record and a recipient file for each type:

Error logging

Error log records are written to error.log in the current directory, as determined thus:

<log id='elogger'>
  <format>%d: [%t] (%h): %s</format>

Statistical logging

Statistical log records used for tracking purposes are written to record.log in the current directory, as determined thus:

<log id='rlogger'>
  <format>%d %h %s</format>

Log records of this type are written when a client connects to the server and when a client disconnects.

Furthermore, we can use the debugging switch (-D) when we start the server and have debugging and trace output written to STDERR.

If Your Server Doesn't Start

A number of likely candidates might have prevented your server from starting.

Bad XML configuration

It is not difficult to make errors (typographical or otherwise) in the server configuration. The first line of defense is to be careful when editing your jabber.xml file. After that, the Jabber server isn't going to be too forthcoming with information if you have broken the well-formedness of the XML:

yak:~/jabber-1.4.1$ ./jabberd/jabberd -h yak
Configuration parsing using jabber.xml failed

Help is at hand in the shape of Perl and the XML::Parser module, which is a wrapper around the XML parser, expat.

Providing you have Perl and the XML::Parser module installed, you can get expat to give you a clue where the XML is broken:

yak:~/jabber-1.4.1$ perl -MXML::Parser 
      -e 'XML::Parser->new->parsefile("jabber.xml", ErrorContext => 3)'
not well-formed (invalid token) at line 47, column 35, byte 1750:
    be on one line, the server doesn't like it otherwise! :)
    <host><jabberd:cmdline flag="h"yak</jabberd:cmdline></host>
    This is the custom configuration section for the
 at /usr/local/lib/perl5/site_perl/5.6.0/i586-linux/XML/Parser.pm line 185

This shows us exactly where the problem is.[1] In this case, the close-tag symbol (>) had been inadvertently removed when replacing localhost with yak.

No XML Is Bad XML!

If you don't use the -c switch to specify which configuration file to use, the standard jabber.xml is used. If that file can't be found, you get exactly the same error as if your XML was not well-formed. You've been warned!

Unable to listen on port(s)

Taking the standard jabber.xml configuration, the Jabber server tries to bind to and listen on two ports: 5222 (for client connections) and 5269 (for server-to-server connections). If other processes are listening to these ports, then the Jabber server can't start and you'll see something like this in the error log:

20010407T12:11:06: [alert] (-internal): io_select unable to listen 
     on 5222 [(null)]
20010406T12:11:06: [alert] (-internal): io_select unable to listen 
     on 5269 [(null)]

If this is the case, use the netstat command to check the status of the ports:

yak:~/jabber-1.4.1$ netstat -an | grep -E '5222|5269'
tcp        0      0  *               LISTEN
tcp        0      0  *               LISTEN

If you see entries like this, it means that processes have been bound to these ports on all IP addresses.[2] For example, if is being listened to then you may have another instance of a Jabber server already running.

On some BSD systems, you cannot bind to the "default" null address; the same error messages will be issued as if the ports were already bound. In the standard jabber.xml configuration file, a bind to the null address is specified for each port as standard; you must change this and specify an explicit IP address for each of the ports in the configuration. That is, instead of:

<ip port="5222"/>

do something like this:

<ip port="5222"></ip>

1.Better highlighting of problems in parsing the configuration file is available in Version 1.4.2 of the server. You're told where the configuration is broken or if there were problems opening the file.

2.This "all" relates to the (null) shown in the unable-to-listenerror messages shown earlier.

To page 1To page 2current page

Created: January 22, 2002
Revised: January 22, 2002

URL: http://webreference.com/programming/jabber/chap3/2/3.html