Does JBoss EAP support the use of WebSockets?

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 4.x
    • 5.x
    • 6.x
    • 7.x

Issue

  • Does JBoss EAP support the use of WebSockets?
  • If it's not supported with current EAP version then please let us know starting which version of EAP we have/will have Websockets support.
  • Does JBoss EAP 6.4 support the use of WebSockets as up till EAP 6.3 it seems that WebSockets is NOT SUPPORTED in production environments. We would like to know if WebSockets are still UNSUPPORTED in productions environments for EAP 6.4 or not?
  • Are websockets via nio or apr recommended?
  • Are websockets supported with mod_cluster?

Resolution

Content from jcp.org is not included.JSR 356 created a standard API for WebSockets in Java in May, 2013

WebSockets 1.0 protocol provides two way communication between web clients and servers. Communications between clients and the server are event-based, allowing for faster processing and smaller bandwidth compared with polling-based methods.

Support for WebSockets


Red Hat provides production support for `WebSockets` in the following releases

Unsupported versions

WebSockets with mod_cluster


JBCS httpd 2.4.23/mod_cluster 1.3.5.Final have been tested and certified with websockets against EAP 7. But note there is still a major usability issue from [MODCLUSTER-580](https://issues.jboss.org/browse/MODCLUSTER-580) / [JBCS-425](https://issues.redhat.com/browse/JBCS-425), which means it can only handle ws communication by itself. Any non-ws http request will fail so this still needs further improvement in later releases for most configurations that would need both ws and non-ws http requests. The last currently known issue impacting non-ws http requests with webocket proxying enabled is [JBCS-1075](https://issues.redhat.com/browse/JBCS-1075) and this will be addressed with JBCS httpd 2.4.37 SP8+.

WebSockets with mod_proxy_balancer


There is a module for Apache called `mod_proxy_wstunnel` which handles proxying for webSockets. This module is currently available in JBoss Web Server 3.0 Apache HTTPD and higher. The configuration example is as below:
  1. Uncomment the following lines in httpd.conf:
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
  1. For proxing to a single node, create a new file '$HTTPD_HOME/conf.d/mod_proxy_wstunnel.conf' with the following:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName localhost
ServerAlias localhost


RewriteEngine On
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /app(.*) ws://localhost:8080/app$1 [P,L]

ProxyPass /app http://localhost:8080/app
ProxyPassReverse /app http://localhost:8080/app


<Proxy *>
      Order deny,allow
      Allow from all
</Proxy>
</VirtualHost>
  1. To use a balancer, create a new file '$HTTPD_HOME/conf.d/mod_proxy_wstunnel.conf' :
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName localhost
ServerAlias localhost

   <Proxy balancer://wscluster>
       BalancerMember ws://127.0.0.1:8080 route=node1
       BalancerMember ws://127.0.0.1:8180 route=node2
       ProxySet stickysession=JSESSIONID|jsessionid
   </Proxy>

   <Proxy balancer://httpcluster>
       BalancerMember http://127.0.0.1:8080 route=node1
       BalancerMember http://127.0.0.1:8180 route=node2
       ProxySet stickysession=JSESSIONID|jsessionid
   </Proxy>

   RewriteEngine On
   RewriteCond %{HTTP:Connection} upgrade [NC]
   RewriteCond %{HTTP:Upgrade} websocket [NC]
   RewriteRule /app(.*) balancer://wscluster/app$1 [P,L]

   ProxyPass /app balancer://httpcluster/app
   ProxyPassReverse /app balancer://httpcluster/app
</VirtualHost>
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.