Site Contents
My Blog
Wireless & Networking
Hardware & Gadgets
Software Picks
Contact Me

My Articles & Papers
Flex Performance
Server/Client Under the Hood
Multiple Instances of CFMX
Multiple Instance Config
NLB with ColdFusion
Clustering CFMX for J2EE
Multi-Tier Hardware LB w CFMX
Cisco CSS & Coldfusion MX
JRun 4 Jini based Clustering
WiFi Growth

2ID Tacweb

Other Hobbys
Body-For-Life Challenge

Personal Projects
Family Pool
Deck Gate


GoogleTalk via ColdFusion MX 7 XMPP gateway

This is from Peter Reese in ColdFusion support and I thought I would share his experience.

I attended a Ben Forta presentation discussing CFMX 7 event gateways.  I found for the most part it was information that was covered in the event gateways brown bag last year before CFMX 7 came out.  However, one point I found interesting and can share was that we now have available an open IM network that we can utilize XMPP on – Google Talk.  XMPP is one of the default gateways that ship with CFMX 7. 

It seems this has been a trendy thing to play with recently.  Here is Damon Cooper’s blog discussing his tests:

So I created a couple Google Talk accounts and started playing with the gateway to get them talking.  I needed to provide a cell phone number that can accept SMS messages to create the gmail accounts to use with Google talk.  Luckily I had my phone as well as my wife’s to set two accounts up.

It was pretty easy to get going.  It took maybe an hour.  It’s a great way to get into using event gateways if you haven’t tried setting one up. 

I utilized the basic “echo” application to run a hello world type test.

First, I needed to create an event gateway.  I went into the CF Admin and under “Event Gateways” and “Gateway Instances” I chose “Add” and entered the following values:

Gateway ID: GoogleTalk
Gateway Type: XMPP – XMPP Gateway
CFC Path: {cf.rootdir}/gateway/cfc/examples/echo.cfc
Configuration File: {cf.rootdir}/gateway/config/xmpp.cfg

Then, I had to set up a few files before the gateway instance would start.  The echo.cfc and xmpp.cfg existed, but needed to be modified slightly to work with Google Talk.

Resources I used to determine the correct values and other information are in these pages:

Livedocs for onAddBuddyRequest – stole this code to set up the echo.cfc to allow the add buddy request

Google Talk for developers FAQ – helps with settings in XMPP.cfg

Here are the modified files:

# XMPP Instant Message Configuration file
# This is the XMPP Instant Message Server username to be used by the Gateway
# e.g. #enter your gmail account here - pete

# This is the password for the above username
password=password #enter your gmail password here - pete

# This is the resouceName used to identify your loggin instance
# Optional settings
# secureprotocol = TSL or SSL
# if SSL specified, use must specify ip and port of secure server
# securerequirement = true or false
# whether a secure connection to the server is required. If server
# connection will only succeed if a secure connection was
# successfully established.
# Specify Server and Port settings to overwrite
# See {cf.root}/gateway/lib/ to check default settings
# if secureprotcol is specify as SSL then serverip and port need to be specified
# secure port use to be 5223
# This is how many times you would like to retry to
# connect to the XMPP server if the Gateway gets disconnected
# or on startup. 0 means not to retry, -1 means try forever.
# The default is -1 (forever)
# This is the number of seconds to wait between connection
# attempts.  The minimum is 1 second.
# The default is 5 seconds.
# Default method names, if they are not specified, we use default
# If they specified, then we use their name as CFC method names
# If the value is an empty string such as 'onBuddyStatusFunction='
# then it means we don't send this type of event in IM Gateway

Plenty of unnecessary code in the echo.cfc below.  I just wanted to get it working.  It accepts all requests.

<cfcomponent displayname="echo" hint="Process events from the test gateway and return echo">
<cffunction name="onIncomingMessage" output="no">
<cfargument name="CFEvent" type="struct" required="yes">
<!--- Get the message --->
<cfset data=cfevent.DATA>
<cfset message="#data.message#">
<!--- where did it come from? --->
<cfset orig="#CFEvent.originatorID#">
<cfset retValue = structNew()>
<cfif listcontains("XMPP,SAMETIME,YIM,AIM,MSN,ICQ,JSC", arguments.CFEVENT.GatewayType) gt 0>
<!--- gateway types YIM, AIM, MSN, ICQ and JSC are supported by JBuddy-CF --->
<cfset retValue.BuddyID = orig>
<cfset retValue.MESSAGE = "echo: " & message>
<cfelseif arguments.CFEVENT.GatewayType is "Socket">
<cfset retValue.originatorID = orig>
<cfset retValue.message = "echo: " & message>
<cfelseif arguments.cfevent.gatewaytype is "SMS">
<cfset retValue.command = "submit">
<cfset retValue.sourceAddress = arguments.CFEVENT.GatewayID>
<cfset retValue.destAddress = orig>
<cfset retValue.shortMessage = "echo: " & message>
<!--- send the return message back --->
<cfreturn retValue>
<cffunction name="onAddBuddyRequest">
<cfargument name="CFEvent" type="struct" required="YES">
<cflock scope="APPLICATION" timeout="10" type="EXCLUSIVE">
	// If the name is in the DB once, accept; if it is missing, decline.
	// If it is in the DB multiple times, take no action.
reason="Valid ID";
	//Add the buddy to the buddy status structure only if accepted.
if (NOT StructKeyExists(Application,"buddyStatus")) {
if (NOT StructKeyExists(Application.buddyStatus,
CFEvent.Data.SENDER)) {
Application.buddyStatus[#CFEvent.Data.SENDER#].status="Accepted Buddy Request";
<!--- Log the request and decision information. --->
<cflog file="#CFEvent.GatewayID#Status" text="onAddBuddyRequest; SENDER: #CFEvent.Data.SENDER# MESSAGE:
<!--- Return the action decision. --->
<cfset retValue = structNew()>
<cfset retValue.command = action>
<cfset retValue.BuddyID = CFEvent.DATA.SENDER>
<cfset retValue.Reason = reason>
<cfreturn retValue> 
<cffunction name="onAddBuddyResponse">
<cffunction name="onBuddyStatus">
<cffunction name="onIMServerMessage">


I also had to add an Application.cfm in the {cfroot}/gateway/cfc/examples/ directory to use the application scope in echo.cfc.  Nothing tricky here:


<cfapplication name="testXMPP" sessionmanagement="Yes" 
setclientcookies="Yes" sessiontimeout="#CreateTimeSpan(0,1,0,0)#" >



Once these files are in place, I started the event gateway as well as the Google Talk client on my machine.  I added my machine as a buddy and it worked! 

I found a new log file created by echo.cfc.  In there was this entry:

"Information","Thread-19","09/13/05","01:59:05","TESTXMPP","onAddBuddyRequest; SENDER: MESSAGE: Requesting authorization to add '' to ''  buddy list and view '' presence. TIMESTAMP: {ts '2005-09-13 01:59:05'} ACTION: accept"

There was a lot more trial and error than I’m describing here, but this *hopefully* will work for you right away!

If you run into problems, places to look for issues are in the eventgateway.log and as always, the exception.log.

Good Luck!