Accessibility

Table of Contents

Chatting Through IM Gateways in ColdFusion MX 7

Configuring, Registering, and Starting the XMPP Event Gateway

Save JabberBot.cfc in a logical location on your server. For instance, on my local development server, I created a directory called "jabber" under the ColdFusion web root and placed JabberBot.cfc in that directory.

You may have been wondering how the JabberBot CFC knows how to log on to the Jive Messenger server. The answer is that each event gateway instance is able to have a configuration file associated with it. In some cases a configuration file isn’t necessary, but JabberBot needs to have a configuration file containing the XMPP server location and its buddy ID and password to work its magic.

ColdFusion contains a sample configuration file for each of the event gateways that ship with it. In a standalone installation the configuration files on Windows are in C:\CFusionMX7\gateway\config, and in a multi-instance or J2EE installation the configuration files are located under the server instance’s web root in the WEB-INF/cfusion/gateway/config directory. You are using the XMPP gateway, which uses the xmpp.cfg file. You can use these gateway files as templates when you create new gateway files, but you don’t need to edit any of these files now.

For this tutorial, I provided a file called cfjabber.cfg (in the ZIP for this tutorial). You will edit this gateway file based on the following specifications:

  1. Open cfjabber.cfg (in any text editor) and update the following lines:

    • userid: Set this to the Jabber ID you gave the ColdFusion user you created previously, for example cfserver@127.0.0.1
    • password: Set this to the password for you ColdFusion Jabber user
    • resourceName: This is a handle used for your login instance. I just changed this to ColdFusion (again being a fountain of creativity)
    • serverip: Enter 127.0.0.1
    • serverport: Enter 5222

    You can leave the rest of the configuration file as is.

  2. Save the updated file. I suggest saving the file in the same directory as JabberBot.cfc.
  3. Log on to your ColdFusion administrator and click the Event Gateways section on the left.
  4. Click Gateway Types.

    Note: This screen shows you all the gateways installed on the server. Use this section to install any new gateways. The XMPP Gateway is already installed so you don’t need to do anything here now. I’m just pointing this out to show you where ColdFusion gets the available gateway types in the next step.

  5. Click Gateway Instances in the left-side menu. Here, you configure JabberBot.cfc as an instance of the XMPP gateway.
  6. Enter the following information to complete the form:

    1. Gateway ID: This can be anything; I used JabberBot for simplicity’s sake.
    2. Gateway Type: Select XMPP – XMPP Gateway from the pop-up menu.
    3. CFC Path: Browse to or type the location of JabberBot.cfc here. This is the full drive path to the location of the CFC. My location was: C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\jabber\JabberBot.cfc but yours will be different based on your ColdFusion installation configuration and where you placed your CFC.
    4. Configuration File: Browse to or type the location of the JabberBot configuration file (cfjabber.cfg) here.
    5. Startup Mode: This tells ColdFusion to start the gateway instance automatically when ColdFusion starts, if the instance should be started manually, or to disable the instance. If you want to be able to chat with your ColdFusion server automatically after a server restart, set this to automatic. (If you find yourself talking to your ColdFusion server a bit too much, you might also want to consider hanging out with some real human beings on occasion!)

    Figure 6. Adding an Event Gateway Instance

    Figure 6. Adding an Event Gateway Instance

    (+) View larger

  7. Click Add Gateway Instance. The gateway instance appears in the list of instances at the bottom of the screen.
  8. Click the green Play button next to your instance to start the instance. A message displays "Starting" in yellow, but the screen doesn’t automatically refresh to show you when it reaches "Running" status. If you want to verify that it is running, click the Refresh button at the bottom of the instances list. Once your JabberBot gateway is running, your ColdFusion server is ready for Jabber traffic!

    Figure 7. The list of gateway instances and their status

    Figure 7. The list of gateway instances and their status

One final note before proceeding: When you work with event gateways, you become very good friends with the cflog tag and the eventgateway.log file that appears in the ColdFusion Administrator Log Files section. If you start modifying JabberBot or creating your own IM gateways (come on, you know you want to) you’ll notice that when an error occurs you will see nothing in your IM client. It’s useful to either use the cflog tag to log information from your CFC, or, I’ve found that the eventgateway.log file that exists by default in ColdFusion does well with providing information that helps pinpoint solutions to an error. These are just a couple of pointers to avoid the frustration of the "white screen of death" in your Jabber client.