ejabberd Cannot Connect to Some Servers: Fix DNS SRV

Error

I cannot connect to some servers like gmail.com and jabber.ccc.de, but I can connect to almost any other Jabber server. Logs show that some communication is started, but for some reason the negotation fails:

=INFO REPORT==== 2006-01-21 14:58:52 ===
I(<0.1527.0>:ejabberd_s2s_out:104): started: {"myserver.com",
                                              "gmail.com",
                                              {verify,
                                                  <0.1525.0>,
                                                  "2334ASDA2424AASDASDADS124343434343423FAFASFKKG74521",
                                                  "606104456"}}

=INFO REPORT==== 2006-01-21 14:59:12 ===
I(<0.1525.0>:ejabberd_s2s_in:501): terminated: normal

Explanation

Certain Jabber servers are installed in a specific way and your Jabber server must support DNS SRV Records resolving in order to connect to them. Erlang/OTP implements this, but works correctly only when using the command line parameter '-name nodename'. It doesn't work correctly when using the parameter '-sname nodename'.

Solution 1: Use the Host Resolver

  1. Create the file /etc/ejabberd/inetrc and put the following line into it:

    {file, resolv, "/etc/resolv.conf"}.

    Do not forget to put the dot at the end of the line.

  2. Add the following option to your ejabberd command line:

    -kernel inetrc \"/etc/ejabberd/inetrc\"

    Another way to indicate this file is adding an environment variable to your ejabberd start script:

    ERL_INETRC=/etc/ejabberd/inetrc
    export ERL_INETRC
    erl -sname ...

  3. Now try to discover jabber.ccc.de or login on a Google Talk with a Jabber client and try to discover your Jabber server.

Solution 2: Add IP Address Manually

Another possibility is to add manually the IP address. This solution should be avoided.

  • To be able to connect to Google Talk (gtalk), add to the /etc/hosts file this line:

    gmail.com 216.239.37.125

    But if you are on Microsoft Windows the file is called C:\WINDOWS\system32\drivers\etc\hosts and the line to add is slightly different:

    216.239.37.125 gmail.com

Solution 3: In Windows, Add DNS Servers Manually

In Windows, the inetrc file installed by ejabberd in conf/ directory may not work correctly. If DNS SRV does not work correctly even when that file is used, edit it and add manually some DNS servers. In this example the IP addresses of OpenDNS are added:

{nameserver, {208,67,222,222}}.
{nameserver, {208,67,220,220}}.
{registry, win32}.

Related Links

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Still no luck on Windows platform

Unfortunately, it seems like this problem still persists, and I haven't found any solution for windows platform. Windows version uses inetrc.win file, and the only string there is

Quote:

{registry, win32}.

So variant #1 isn't acceptable. Modifying hosts file doesn't help either, and doesn't look like a good solution too. My server can communicate with other jabber servers, but I get "remote server not found" error when I try to get to GTalk.
I tried using "-name" and "-sname" options but with no luck. Both return

Quote:

{error, timeout}

Maybe somebody has any ideas? I'm using ejabberd 1.1.4_2.

editing hosts

editing hosts worked for me but it needed some time and a dns flush to take effect...
I only tried with jabber.ccc.de though. Didn't test with gmail.

So, which of these solutions

So,

which of these solutions works on a windows installation?
Only editing the system's hosts?

Also: inetrc is not used on windows, and inetrc.win doesn't seem to do anything.

a 4th solution

A found a 4th solution here

http://easyerl.blogspot.com/2007/06/configuring-your-dns-server-for-inet...

you can put

inet_db:add_ns({208,67,220,220}).

in the application code. worked on windows!

correct order in /etc/hosts file

There is no order difference between the hosts file in Unix/Linux and Windows. Both are putting the IP first then the DNS names and aliases latter.

dnsmasq filterwin2k

I just spent a couple of hours scratching my head trying to figure out why I couldn't get a s2s connection to gtalk to work - turns out it was dnsmasq - the "filterwin2k" option stops it forwarding SRV requests.

dnsmasq s2s conections problem

thx man, how did you find out? spended hours to find out why i can't connect to all jabber-servers. it was a stupid openwrt update i did recently. is bogus-priv in there save?

Can I ask for a

Can I ask for a clarification? When you say "add the following to your ejabberd command line", should that be added to

$ su ejabberd -c "/usr/sbin/ejabberd -noshell -detached"

like this:

$ su ejabberd -c "/usr/sbin/ejabberd -kernel inetrc \"/etc/ejabberd/inetrc\" -noshell -detached"

It seems to fail to start when I do so.

Being thoroughly unfamiliar with erlang, I'm afraid I don't know what debugging information might help, but I'll be glad to provide any.

I figured this out: it needs

I figured this out: it needs the quotes, so they must be escaped from the shell. In the start script, the string is already quoted, so the backslashes must also be escaped so that they will be passed through. Thus:

$ su ejabberd -c "/usr/sbin/ejabberd -kernel inetrc \\\"/etc/ejabberd/inetrc\\\" -noshell -detached"

in the start script works.

Problem reappeared

I used the second fix above (altering the hosts file) back in January to make my ejabberd 1.0.0 (I think -- is there any easy to find out?) talk to GTalk, but it seems to have stopped working.

In Psi, I use service discovery from my server and it can see other Jabber servers (eg Jabber.org or jabber.dk but when I try googlemail.com it never resolves (the spinner keeps spinning).

When I try doing service disco from GTalk (I have that set up as an account in Psi) to my server, I get this error: "There was an error getting agents for . Reason: "

This is the line in my hosts file:

Quote:

216.239.37.125 gmail.com googlemail.com

Any ideas?

Edit: never mind: updating the IP address to the new one for talk.google.com (209.85.137.125) fixed it.

R11B

Out of interest, did Erlang R11B fix this bug?

You can easily test it. Just

You can easily test it. Just run nondistributed erlang or erlang with short name (erl or erl -name qwerty) and try the following:

inet_res:getbyname("_xmpp-server._tcp.jabber.ru",srv).

If the result is

{error, timeout}

then this bug isn't fixed.

Tested and failed: not solved

I tried with both Erlang R10B-10 and R11B-0 compiled from source, and the results are the same:

$ erl -sname qwe
Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]

Eshell V5.5  (abort with ^G)
(qwe@atenea)1> inet_res:getbyname("_xmpp-server._tcp.jabber.ru",srv).
{error,timeout}

Of course it works correctly, as usual, when using -name:

$ erl -name qwe
Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]

Eshell V5.5  (abort with ^G)
(qwe@atenea.pike)1> inet_res:getbyname("_xmpp-server._tcp.jabber.ru",srv).
{ok,{hostent,"_xmpp-server._tcp.jabber.ru",[],srv,1,[{0,0,5269,"jabber.ru"}]}}

So I guess it isn't solved yet.

Syndicate content