Websocket / Flashsocket / Play! Framework
It was one of those late nights for me. You know the ones where you think your on to something but your not sure if your mind is all there?
Anyway I have been working on some new tech stuff trying to find the best solution to get websockets to work in the Play! Framework - http://playframwork.org. They already had some support for websockets but since the upgrade to Chrome14 things broke. I ended up digging in and forking Play from github to see if I could hack my way around enough to make it work. I ended up learning more then I was planning on when it comes to the nitty gritty of websockets.
Last week when Chrome14 was released to the wild they had changed the websocket spec to only work with Hybi-10, the latest websocket draft. Play only supported Hixie-76. After digging around on the net I was able to find this nice open source project that contained Netty code for the updated spec: https://github.com/joewalnes/webbit. He also supported Hixie-76 as well as Hixie-75 so I figured I would add them all to Play. The playframework code was pretty straight forward so I could find where the current support was and add the new protocol parts to it. After a bunch of trial and error I got a working version using Chrome14 and Safari5.
The next thing was flashsocket support. This is actually where this whole thing started. Unfortunately we can’t require people to use Chrome so IE support is necessary. I found this nice little piece of client code that allows seamless fallback support to flashsockets when websockets are not available: https://github.com/gimite/web-socket-js. This only supported hybi-10 so its good I was able to put that in place. I still had a problem though, the FlashSocketPolicy that is required. I searched around some more and found another nice project that offered that in netty: https://github.com/cgbystrom/netty-tools. After adding some classes from this project my request pulled down the valid FlashSocketPolicy file and was able to connect using Firefox5.
So there you have it. I wasn’t totally fooling myself in the middle of the night and am hoping play will merge in my changes for the pull request I submitted. https://github.com/playframework/play/pull/352