[ejabberd] max_stanza_size not working in mod_http_bind?

Andreas Ko"hler andreas.koehler at 1und1.de
Sat Apr 25 21:09:07 MSD 2009


Badlop wrote:
> 2009/4/11 Xia Qingran <qingran.xia at gmail.com>:
>> I want to limit the max length of messages sending by XMPP web client(
>> JWCHAT ), and I have taken a client check by Javascript. Moreover I
>> must take this limitation on server side of mod_http_bind.
>> With the help of the issue,
>> https://support.process-one.net/browse/EJAB-416, I have taken the
>> max_stanza_size in ejabberd_c2s:
>>  {5222, ejabberd_c2s, [
>>                        {certfile, "/usr/local/etc/ejabberd/xmppserver.pem"}, starttls,
>>                        {access, c2s},
>>                        {shaper, c2s_shaper},
>>                        {ip, {127, 0, 0, 1}},
>>                        {max_stanza_size, 4096}
>>                       ]},
>> Is this way right?
> 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.

Actually, that seems to be documented in the Installation and Operation
Guide, see http://www.process-one.net/en/ejabberd/guide_en#htoc23

"""This option specifies an approximate maximum size in bytes of XML
stanzas. Approximate, because it is calculated with the precision of one
block of readed data."""

So, a max_stanza_size error is only triggered if the data fed into
xml_stream:parse/1 completely belongs to a single stanza that

(1) has not ended yet, and
(2) contains more than max_stanza_size bytes already

The 2536 bytes you mention may reflect the MTU of your connection.  For
HTTP Binding, the XML stream gets the data after it has been received as
part of the HTTP request completely though.  BOSH even forbids stanzas
to be sent split up into several requests.  Personally, I would regard
EJAB-243 as unfixed.

BTW, parsing HTTP Binding content twice
(ejabberd_http_bind.erl:parse_request/1, Payload =
[xml:element_to_string(E) || E <- FixedEls]) looks clumsy.

-- Andreas

More information about the ejabberd mailing list