WebSockets for JBoss AS7
Latest commit fd03a4e Sep 26, 2012 @mikebrock Merge pull request #7 from pmiklos/master
Fix for #6
Failed to load latest commit information.
src Fixed #6 so the response header Sec-WebSocket-Protocol is set to null Sep 25, 2012
.gitignore add .gitignore Apr 10, 2012
README.md fix README May 14, 2012
pom.xml refactor May 3, 2012


WebSockets for JBoss AS 7.1.2+

NOTE: This does not currently work on versions of AS older than 7.1.2. It also requires use of the Apache Portable Runtime connector (APR). This limitation will be addressed in a future version of AS.

To Configure APR in JBoss AS 7.1.x:

  1. In domain/configuration/domain.xml: Change Line:

     <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">           


     <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="true">
  2. Okay, done.

Using the WebsocketServlet:

Once AS 7.1.2+ is configured as specified above, using websockets is as simple as implementing a Servlet which extends org.jboss.as.websockets.servlet.WebsocketServlet and implements its abstract methods. You map the servlet as you normally would, and that servlet mapping will become the upgradable WebSocket path.

Example Implementation:

public class MyWebSocketServlet extends WebSocketServlet {

  protected void onSocketOpened(WebSocket socket) throws IOException {
    System.out.println("Websocket opened :)");

  protected void onSocketClosed(WebSocket socket) throws IOException {
    System.out.println("Websocket closed :(");

  protected void onReceivedFrame(WebSocket socket) throws IOException {
    final Frame frame = socket.readFrame();
    if (frame instanceof TextFrame) {
      final String text = ((TextFrame) frame).getText();
      if ("Hello".equals(text)) {
        socket.writeFrame(TextFrame.from("Hey, there!"));


  1. Message fragmentation is not yet supported.

Known Compatibility

  • Confirmed Working:
    • Chrome 18
    • Firefox 11
    • Safari 5.1
    • MobileSafari on iOS 5.1

Want to Contribute?

Just fork.