google talk for google apps users

I was playing with building an XMPP bot at the weekend. The trouble was my google talk account, but it’s part of google apps for your domain. Why does this matter? Take a look at my ID:

When you feed this to an XMPP library (xmpp4r-simple in my case), it attempts to find a server located at Which isn’t correct, my server is or somesuch.

But there’s a get-out clause in the spec (RFC3920).

Client-to-server communications MUST NOT proceed until the DNS hostname asserted by the server has been resolved. Such resolutions SHOULD first attempt to resolve the hostname using an [SRV] Service of “xmpp-client” and Proto of “tcp”, resulting in resource records such as “” (the use of the string “xmpp-client” for the service identifier is consistent with the IANA registration). If the SRV lookup fails, the fallback is a normal IPv4/IPv6 address record resolution to determine the IP address, using the “xmpp-client” port of 5222, registered with the IANA.

So, all it takes to get this working is some DNS tomfoolery. I added this to the zone file for mydomain.com1:

_xmpp-client._tcp.gapps IN SRV 5  0 5222
_xmpp-client._tcp.gapps IN SRV 20 0 5222
_xmpp-client._tcp.gapps IN SRV 20 0 5222
_xmpp-client._tcp.gapps IN SRV 20 0 5222
_xmpp-client._tcp.gapps IN SRV 20 0 5222

Where did I find this information from? Well, it wasn’t on google’s help, but the DNS can tell me. There’s no XMPP server on, yet you can still use your gmail address as a JID.

  host -t srv

Now I can sign on as — lovely!

1 The privileges of being an ex-sysadmin. 🙂

2 Comments to google talk for google apps users

  1. Scott Laird says:

    It’s documented, it’s just easy to miss. Go to the domain admin page and click on chat settings. It says “[t]o let users chat outside the Google network, you will need to edit your Service (SRV) records in domain settings” and then links to

    • dom says:

      @scott Thanks, but that’s subtly different. That’s about server to server communication, not client to server communications. Of course the only reason I know this is that I found that page, tried it and it didn’t work. 🙂