atom feed5 messages in org.apache.tomcat.devWebSockets in Tomcat 6
FromSent OnAttachments
Filip Hanik Mailing ListsMar 14, 2012 10:42 am 
Mark ThomasMar 15, 2012 5:53 am 
Filip Hanik - Dev ListsMar 15, 2012 7:07 am 
Costin ManolacheMar 15, 2012 10:51 am 
Filip Hanik Mailing ListsMar 16, 2012 8:42 am 
Subject:WebSockets in Tomcat 6
From:Filip Hanik Mailing Lists (
Date:Mar 14, 2012 10:42:02 am

Attached is a patch that leverages the Tomcat WebSocket API with minimalistic
changes and uses that to implement WebSockets in Tomcat 6.0.x

This implementation doesn't touch the endpoints or any real connector logic,
making it risk free. The only change that could do anything, would be the
XXXProcessor + if (statusCode == HttpServletResponse.SC_SWITCHING_PROTOCOLS) { + outputBuffer.addActiveFilter + (outputFilters[Constants.IDENTITY_FILTER]); + } else

Where it sets an identity filter when the user is switching protocols. Otherwise
Tomcat defaults to chunked encoding. You can still see Tomcat 8 sends a Transfer-Encoding:chunked as part of a web socket response.

This implementation also works with BIO connector, as Tomcat's CometProcessor
interface supports both, and let's the implementer implement both Comet and non
Comet in the same class.

Hopefully this patch shows 1. It's fairly risk free to implement this in stables branches as Tomcat 6, and
possibly Tomcat 7 (as we may want to treat this as fairly stable and minimize
refactoring this late in the game) 2. Performance of Comet is similar to the non Comet implementation 3. It took me 4 hours to do this migration, so it's definitely very easy to work
with Comet once you have the bulk work done (the WebSocket protocol impl by Mark

The test suite report is at

I would suggest we consider this for Tomcat 6(my experience is still most users
are using this version). For Tomcat 7, I would recommend it, as it avoids
refactoring, but I'm pretty neutral about it.