| From | Sent On | Attachments |
|---|---|---|
| Filip Hanik Mailing Lists | Mar 14, 2012 10:42 am | |
| Mark Thomas | Mar 15, 2012 5:53 am | |
| Filip Hanik - Dev Lists | Mar 15, 2012 7:07 am | |
| Costin Manolache | Mar 15, 2012 10:51 am | |
| Filip Hanik Mailing Lists | Mar 16, 2012 8:42 am |
| Subject: | WebSockets in Tomcat 6 | |
|---|---|---|
| From: | Filip Hanik Mailing Lists (devl...@hanik.com) | |
| Date: | Mar 14, 2012 10:42:02 am | |
| List: | org.apache.tomcat.dev | |
http://people.apache.org/~fhanik/reports/servers/
Attached is a patch that leverages the Tomcat WebSocket API with minimalistic
changes and uses that to implement WebSockets in Tomcat 6.0.x
http://people.apache.org/~fhanik/websockets-for-tomcat-6.patch
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
Thomas)
The test suite report is at http://people.apache.org/~fhanik/reports/servers/
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.
Filip





