Bug 56187 - Websocket text buffer maximum limit does not change from default 8192.
Summary: Websocket text buffer maximum limit does not change from default 8192.
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.52
Hardware: PC All
: P2 blocker (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Keywords: APIBug
Depends on:
Reported: 2014-02-25 13:17 UTC by Shailesh
Modified: 2019-09-02 05:22 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Shailesh 2014-02-25 13:17:26 UTC

I tried to increase the text message buffer from default value of 8192 by adding context parameter in web.xml of my application as follows,


but even after that it does not change and payload of size greater than 8192 bytes is cut and sent in separate frame. 

I am using Atmosphere library 1.0.18 for server event push but because of the tomcat max. buffer size, it is not able to send large payload, causing to go away from websocket and use long polling.

Comment 1 Shailesh 2014-02-25 13:19:11 UTC
The issue is reproduceable  on Linux also.
Comment 2 Konstantin Kolinko 2014-02-25 13:46:10 UTC
There are 2 different web socket protocol implementations available in Tomcat 7:
1) JSR-356 (a new one)
2) legacy

The settings that you changed are used by the JSR-356 implementation only.

I do not really know what websocket implementation Atmosphere 1.0.18 is using. It is up to you to find out. 

As Bugzilla is not a support forum,
ask on the users mailing list for a help to debug your issue.
Comment 3 Shailesh 2014-02-26 07:17:10 UTC
Atmosphere 1.0.18 uses legacy protocol. 

I tried to debug the issue reached to org.apache.catalina.websocket.WsOutbound. 

public static final int DEFAULT_BUFFER_SIZE = 8192;

public WsOutbound(UpgradeOutbound upgradeOutbound,
            StreamInbound streamInbound) {
        this(upgradeOutbound, streamInbound, DEFAULT_BUFFER_SIZE,

The CharBuffer created with the capacity of DEFAULT_BUFFER_SIZE which is 8192. 

There is no way to change the buffer size. 

I think max. buffer size should be configurable so that it can be set as per the requirement.
Comment 4 Mark Thomas 2014-02-27 11:46:44 UTC
Applications using the old API (in this case Atmosphere) have an API available to change the buffer size if they wish.

Applications have an API they can use to output binary messages that bypasses the buffer entirely.

The buffers are always used when writing text messages and may be used when writing binary messages.

Tomcat imposes no limits on the size of a message that is written. The buffer merely controls the frame size when writing large text messages.

As per the WebSocket specification, frames have no semantic meaning (ignoring extensions which complicate things slightly). Proxies may split frames or merge frames as they see fit. Therefore, I see no reason for Atmosphere to object to large text messages being split into multiple frames.