[ejabberd] strange registration error

Konstantin Khomoutov flatworm at users.sourceforge.net
Fri Sep 18 21:31:11 MSD 2009

Jan Koum wrote:

>>  17/Sep/2009:15:27:36 HARDFAIL command:
>>> [/home/jkoum/ejabberd-2.1.0_beta1/bin/ejabberdctl register xxx
>>> s.example.netyyy] return: 1
>>> {error_logger,{{2009,9,17},{15,27,33}},"Protocol: ~p:
>>> register error:
>>> ~p~n",["inet_tcp",{{badmatch,{error,duplicate_name}},[{inet_tcp_dist,listen,1},{net_kernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p,5}]}]}
>>> while end result is the same, i am curious if this different behavior is
>>> normal or is this some bug we are triggering?
>> This error has nothing to do with user registration,
>> at least not directly. See [1] for explanations.
>> 1. http://www.ejabberd.im/error/duplicate_name

 > i looked at the url but still a bit confused... it says you get this
 > error when trying to start another instance of ejabberd, but i am not
 > starting another instance of ejabberd, just trying to register
 > a user..
The problem is possibly not related to starting *ejabberd itself*
multiple times, but rather to staring two or more instances of 
ejabberdctl at the same time.

My guess goes like this: ejabberdctl is a Unix shell script script which 
ends up calling the Erlang emulator to run the ejabberd_ctl module after 
setting up the environment for this. The erl process is run with either 
the -name or the -sname flag which turns the process into a distributed 
Erlang node (see [1]). Since Erlang nodes must be unique across their 
network, the Erlang subsystem will not let you run more than one node 
with the same name/short name. So if you have a race between ejabberdctl 
runs, the second one will fail.
You can easily see how this occurs:
$ erl -sname foo &
$ erl -sname foo
(see it crash, scroll up to see that badmatch error)
$ rm erl_crash.dump
$ fg
(press ctrl-g, then enter q and hit return)

The solution could be to modify the ejabberdctl code to make random (or 
predictably unique) node name for -name/-sname.

1. http://www.erlang.org/doc/man/erl.html

Please, don't top-post, see 

More information about the ejabberd mailing list