ejabberd 2.1.3 can't login with compression

Hi all!
ejabberd 2.1.3 on freebsd, connection hangs if client use compression even without TLS.

Client-server traffic log:

<?xml version="1.0"?>

<stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="jabber.bryansk.ru" xml:lang="ru" xmlns:xml="http://www.w3.org/XML/1998/namespace">

<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='4261212789' from='jabber.bryansk.ru' version='1.0' xml:lang='ru'>

<stream:features>
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
<compression xmlns="http://jabber.org/features/compress">
<method>zlib</method>
</compression>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
<register xmlns="http://jabber.org/features/iq-register"/>
</stream:features>

<compress xmlns="http://jabber.org/protocol/compress">
<method>zlib</method>
</compress>

server log:

=INFO REPORT==== 2010-05-04 18:12:36 ===
I(<0.461.0>:ejabberd_listener:232) : (#Port<0.811123>) Accepted connection {{10,248,62,200},60565} -> {{10,248,62,2},5222}

=ERROR REPORT==== 2010-05-04 18:12:36 ===
** State machine <0.20667.13> terminating
** Last event in was {xmlstreamelement,
                         {xmlelement,"compress",
                             [{"xmlns","http://jabber.org/protocol/compress"}],
                             [{xmlcdata,<<"\n">>},
                              {xmlelement,"method",[],[{xmlcdata,<<"zlib">>}]},
                              {xmlcdata,<<"\n">>}]}}
** When State == wait_for_feature_request
**      Data  == {state,
                     {socket_state,tls,
                         {tlssock,#Port<0.811123>,#Port<0.811125>},
                         <0.20666.13>},
                     ejabberd_socket,#Ref<0.0.13.11548>,false,"213037150",
                     {sasl_state,"jabber","jabber.bryansk.ru",[],
                         #Fun<ejabberd_c2s.1.70264870>,
                         #Fun<ejabberd_c2s.2.94090657>,
                         #Fun<ejabberd_c2s.3.82359008>,undefined,undefined},
                     c2s,c2s_shaper,true,true,false,true,
                     [verify_none,
                      {certfile,"/usr/local/etc/ejabberd/server.pem"}],
                     false,undefined,[],"jabber.bryansk.ru",[],undefined,
                     {0,nil},
                     {0,nil},
                     {0,nil},
                     {0,nil},
                     undefined,undefined,undefined,false,
                     {userlist,none,[],false},
                     unknown,unknown,
                     {{10,248,62,200},60565},
                     "ru"}
** Reason for termination =
** {{case_clause,{error,{open_error,-11}}},
    [{ejabberd_zlib,enable_zlib,2},
     {ejabberd_socket,compress,2},
     {ejabberd_c2s,wait_for_feature_request,2},
     {gen_fsm,handle_msg,7},
     {proc_lib,init_p_do_apply,3}]}

What's wrong?
SY, Alexander

Re: ejabberd 2.1.3 can't login with compression

This is a typical problem on FreeBSD, dunno why it occurs so often. The problem here is that Erlang is unable to find ejabberd_zlib_drv.so.
Type the following in Erlang shell to find out the source of the problem:

$ erl
Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)

1> {_, Err} = erl_ddll:load_driver("/path/to/ejabberd/shared/objects", ejabberd_zlib_drv).
{error,{open_error,-11}}
2> erl_ddll:format_error(Err).
"error description goes here"

x# erlErlang R13B04

x# erl
Erlang R13B04 (erts-5.7.5) [source] [rq:1] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
1> ejabberd:get_so_path().
"/usr/local/lib/erlang/lib/ejabberd-2.1.3/priv/lib"
2> {_, Err} = erl_ddll:load_driver(ejabberd:get_so_path(), ejabberd_zlib_drv).           
** exception error: no match of right hand side value ok

IMHO, that's something other

Re: ejabberd 2.1.3 can't login with compression

From your stack:

** {{case_clause,{error,{open_error,-11}}},
    [{ejabberd_zlib,enable_zlib,2},
     {ejabberd_socket,compress,2},
     {ejabberd_c2s,wait_for_feature_request,2},
     {gen_fsm,handle_msg,7},
     {proc_lib,init_p_do_apply,3}]}

So there is a case clause in function ejabberd_zlib:enable_zlib/2. In ths function we have only one case:

case erl_ddll:load_driver(ejabberd:get_so_path(), ejabberd_zlib_drv) of
ok -> ok;
{error, already_loaded} -> ok
end,

So ejabberd is unable to load the shared object somehow. I have no idea why it works in your console, but not in running ejabberd. Maybe there is a mess with ejabberd:get_so_path()? Try to call this function in Erlang shell with running ejabberd.

Hacked)

I changed

case erl_ddll:load_driver(ejabberd:get_so_path(), ejabberd_zlib_drv) of

to

case erl_ddll:load_driver("/usr/local/lib/erlang/lib/ejabberd-2.1.3/priv/lib", ejabberd_zlib_drv) of

and it's worked.
Thanks for your help.

Re: ejabberd 2.1.3 can't login with compression

You can just set EJABBERD_SO_PATH environment, no need to hack sources ;)

Ok, after next upgrade i'll

Ok, i'll try after next upgrade )

Syndicate content