Question

I'm looking for a way to check if a server is support xmpp protocol, i.e. xmpp-server is running on this domain.

Maybe special DNS check or something like that?

Was it helpful?

Solution

Most XMPP servers should support at least one of these DNS SRV records:

  • _xmpp-server._tcp.example.com
  • _xmpp-client._tcp.example.com

Some servers may not have these records published, but most of those will not want to talk to the outside world. As an example, you can use "dig" on the command line to check a domain, like this:

% dig +short -t SRV _xmpp-server._tcp.gmail.com.
20 0 5269 xmpp-server2.l.google.com.
20 0 5269 xmpp-server3.l.google.com.
20 0 5269 xmpp-server4.l.google.com.
5 0 5269 xmpp-server.l.google.com.
20 0 5269 xmpp-server1.l.google.com.

"+short" gets rid of a lot of DNS details, "-t SRV" says we want SRV records, and the dot at the end says to ignore your local domain name settings.

(adding in response to @user188719) If you don't find an SRV record, you can try using the original domain name, and assuming port 5222 for client connections or 5269 for server connections.

Once you have the hostname and port number to connect to, you can use telnet hostname port to see if there is a process listening there. However, to really detect if it's an XMPP server at that host/port, send in the start of an XMPP stream. nc or netcat provide a convenient mechanism for this. Example for a server-to-server check:

% echo "<stream:stream to='gmail.com' version='1.0' xmlns='jabber:server' xmlns:stream='http://etherx.jabber.org/streams' xmlns:db='jabber:server:dialback'>" | nc xmpp-server.l.google.com 5269
<stream:stream id="0A44AFB86521393A" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:server" xmlns:db="jabber:server:dialback">

OTHER TIPS

Following Joe's explanation, I personally would check SRV records and fall back to a quick (short timeout) connect check on port 5269. Then cache the result.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top