Re: maxMessageSize of web socket message using cometD javascript library

698 views
Skip to first unread message
Message has been deleted

Pushkar Deole

unread,
Mar 18, 2016, 7:26:26 AM3/18/16
to cometd-users
correcting typo in below post:

"I am NOT able to find similar property for a JavaScript client"

On Friday, March 18, 2016 at 4:53:35 PM UTC+5:30, Pushkar Deole wrote:
Hi,

I am working on a web application in which I make use of CometD javascript library on the client. This cometD client communicates with the CometD Java server deployed in Tomcat.
In my web application, I have integrated a Chat and E-mail client (this is basically an application which will be used by contact centers). Through the Chat and E-mail client, the users can send large amount of text to the other party. While testing these clients, I observed that when I send a text larger than 7.7 KB, the remote request fails and I see the below error message:

connectionType: "websocket"
"The decoded text message was too big for the output buffer and the endpoint does not support partial messages"
websocketCode: 1009

I did a bit of searching around this and came across a configuration property named "maxMessageSize". This property sets the maximum number of bytes allowed for each web socket message. However, this property is available for the Client transport configuration for Java client. I am able to find similar property for a JavaScript client.
Has anyone come across this error for Javascript client library and if yes then can I get some help around this.

Thanks a lot...

Simone Bordet

unread,
Mar 18, 2016, 7:33:45 AM3/18/16
to cometd-users
Hi,

On Fri, Mar 18, 2016 at 12:23 PM, Pushkar Deole <pdeol...@gmail.com> wrote:
> Hi,
>
> I am working on a web application in which I make use of CometD javascript
> library on the client. This cometD client communicates with the CometD Java
> server deployed in Tomcat.
> In my web application, I have integrated a Chat and E-mail client (this is
> basically an application which will be used by contact centers). Through the
> Chat and E-mail client, the users can send large amount of text to the other
> party. While testing these clients, I observed that when I send a text
> larger than 7.7 KB, the remote request fails and I see the below error
> message:
>
> connectionType: "websocket"
> "The decoded text message was too big for the output buffer and the endpoint
> does not support partial messages"
> websocketCode: 1009
>
> I did a bit of searching around this and came across a configuration
> property named "maxMessageSize". This property sets the maximum number of
> bytes allowed for each web socket message. However, this property is
> available for the Client transport configuration for Java client. I am able
> to find similar property for a JavaScript client.
> Has anyone come across this error for Javascript client library and if yes
> then can I get some help around this.

TLDR: split the large messages into smaller ones.

WebSocket messages could be huge, so implementations have to put a
limit on how big they can be to avoid to blow up.
Unfortunately there is no standard. Firefox may support a value,
Chrome another, and the server yet another.
Furthermore the send max message size may be different from the
receive max message size.

Even if you can send a message from Firefox to the server, the server
then broadcasts it to other clients that may have different browsers,
so for some of them the message may be too big and fail.

Exactly because there is no standard, you have to split the message
into multiple pieces if it's too large.

The reason there is no settings for the max message size on the
JavaScript library is because it does not depend on CometD, but on the
browser, and there is no official API that CometD can use to tell the
browser what is the max message size that CometD would like the
browser to support.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.

Pushkar Deole

unread,
Mar 18, 2016, 8:58:11 AM3/18/16
to cometd-users
If it depends on browser, then while splitting a message what should be max size of each of the message parts?
By the way, cometD Java client does have a property called maxMessageSize..

Simone Bordet

unread,
Mar 18, 2016, 10:12:59 AM3/18/16
to cometd-users
Hi,

On Fri, Mar 18, 2016 at 1:58 PM, Pushkar Deole <pdeol...@gmail.com> wrote:
> If it depends on browser, then while splitting a message what should be max
> size of each of the message parts?

Eh, you have to guess :(
However, values like 4-8 KiB should be good; implementations are
typically reasonable.

> By the way, cometD Java client does have a property called maxMessageSize..

Because the implementation that CometD uses for the Java client
(Jetty's WebSocket client) has an API to set the maxMessageSize, which
is absent in the standard JavaScript APIs exposed by browsers.

Pushkar Deole

unread,
Mar 21, 2016, 2:58:33 AM3/21/16
to cometd-users
I believe cometD should handle the splitting of large messages on client and then reconstruct the whole message back on server rather than application handling it.. there would some configuration for this in CometD that I can use?

Simone Bordet

unread,
Mar 21, 2016, 2:29:56 PM3/21/16
to cometd-users
Hi,

On Mon, Mar 21, 2016 at 7:58 AM, Pushkar Deole <pdeol...@gmail.com> wrote:
> I believe cometD should handle the splitting of large messages on client and
> then reconstruct the whole message back on server rather than application
> handling it.. there would some configuration for this in CometD that I can
> use?

So I was wrong in saying that browsers have a limit.
Apparently this was true in the past, but not anymore.
"Browsers don't have a limit" actually means that the limit is high,
perhaps around 2 GiB or until the browser crashes :)

So if you can send and receive from browsers messages of any size,
what remains is for you to configure the server side with a large
enough "maxMessageSize".

The CometD Java client does have a limit, so that also should be
enlarged, if you use it.

No need to split at application level at this point.

Pushkar Deole

unread,
Mar 22, 2016, 2:27:12 AM3/22/16
to cometd-users
yeah.. I set the ws.maxMessageSize property to 65520 on server and I am now able to send larger data..
thanks..
Reply all
Reply to author
Forward
0 new messages