[ejabberd] max_stanza_size not working in mod_http_bind?

Xia Qingran qingran.xia at gmail.com
Tue Apr 14 10:16:27 MSD 2009

2009/4/11 Badlop <badlop at gmail.com>:
> That configuration seems right.
> It isn't documented in ejabberd Guide, but it is mentioned in the
> source code ejabberd_http_bind.erl:
>  %% Read c2s options from the first ejabberd_c2s configuration in
>  %% the config file listen section
>  ...
>  Opts = ejabberd_c2s_config:get_c2s_limits(),
>> And it is not woking when I successfully send and
>> receive a message with 4096 chars.
> Maybe the size calculation in ejabberd is not exact.
> You can try to send messages a little bigger: 4097, or 4100, 4500 or
> 5000, until you find the connection is closed.
> I configured {max_stanza_size, 2000}, and then connected with c2s to
> port 5222, not http-bind. ejabberd allowed me to send messages with
> less than 2536 bytes.
> If I try to send a message with more than 2536 bytes, the client receives:
> <error xmlns='http://etherx.jabber.org/streams'>
>  <xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
> </error>
> and the server closes the connection.
> ---
> Badlop
> ProcessOne

Sorry to give you reply so late. I was testing this for these days and
found that the max_stanza_limit of c2s is not working because I can
send even 5 times bigger length of message. I only take use of this to
protect my ejabberd server against bad guys sending long and useless

I took use of a simple python script to send message with assigned
character numbe and all the sent messages are received by target user:

import xmpp
login = 'testtest8'
pwd   = 'password'
cnx = xmpp.Client('mydomain.org')
cnx.connect(('', 5222))
cnx.auth(login, pwd, 'TEST')
a = '1'
cnx.send( xmpp.Message( "testtest1 at mydomain.org" ,a.zfill(4000) ) )

With Pidgin 2.5.2 and Gajim 0.12.1, I can also sent a message with
about 5 times bigger than max_stanza_size.

I installed ejabberd-2.0.5 with linux x86 32-bits installer and run it
on ubuntu-8.10-i386 by my laptop.
The contents of ejabberd.cfg are listed as follows:
{loglevel, 5}.

{hosts, ["mydomain.org"]}.


  {5222, ejabberd_c2s, [
            {certfile, "/usr/local/ejabberd-2.0.4/conf/server.pem"}, starttls,
            {access, c2s},
            {shaper, c2s_shaper},
            {max_stanza_size, 65536}

  {5280, ejabberd_http, [

{auth_method, external}.
{extauth_program, "/usr/local/bin/ejabberd_extauh.py"}.

{odbc_server, {pgsql, "localhost", "ejabberd", "ejabberd", "ejabberd"}}.
{odbc_pool_size, 5}.

{pgsql_users_number_estimate, true}.

{shaper, normal, {maxrate, 5000000}}.

{shaper, fast, {maxrate, 50000000}}.

{acl, admin, {user, "qingran", "mydomain.org"}}.

{acl, local, {user_regexp, ""}}.

{access, max_user_sessions, [{5, all}]}.

{access, local, [{allow, local}]}.

{access, c2s, [{deny, blocked},
           {allow, all}]}.

{access, c2s_shaper, [{none, admin},
              {normal, all}]}.

{access, s2s_shaper, [{deny, all}]}.

{access, announce, [{allow, admin}]}.

{access, configure, [{allow, admin}]}.

{access, muc_admin, [{allow, admin}]}.

{access, muc, [{allow, all}]}.

{access, register, [{deny, all}]}.

{access, pubsub_createnode, [{allow, all}]}.

{language, "en"}.

%%%   =======

%% Modules enabled in all ejabberd virtual hosts.
  {mod_adhoc,    []},
  {mod_announce, [{access, announce}]}, % requires mod_adhoc
  {mod_caps,     []},
  {mod_configure,[]}, % requires mod_adhoc
  {mod_disco,    []},

  {mod_http_bind,[ {max_inactivity, 10} ]},

  {mod_offline,  []},
  {mod_privacy_odbc,  []},
  {mod_private_odbc,  []},

  {mod_pubsub,   [ % requires mod_caps
          {access_createnode, pubsub_createnode},
          {plugins, ["default", "pep"]}
  {mod_roster_odbc,   []},


  {mod_time,     []},
  {mod_vcard_odbc,    []},
  {mod_version,  []}


Xia Qingran
qingran.xia at gmail.com
Sent from Beijing, 11, China
Vince Lombardi  - &quot;Show me a good loser, and I'll show you a
loser.&quot; - http://www.brainyquote.com/quotes/authors/v/vince_lombardi.html

More information about the ejabberd mailing list