Tuesday Feb 17, 2015

Tyrus and Autobahn|Testsuite compliance

The Tyrus Team has just released Tyrus 1.10 (JSR 356 Reference Implementation). With only a few fixes (see Pavel's blog for details), this release could be seen as a minor one. It is however an important milestone as it is the first Tyrus release that passes the Autobahn|Testsuite, a test harness used to verify WebSocket client and server implementations for specification conformance and implementation robustness.

In this release, the Tyrus Team has also introduced 2 new samples that explore ways of sharing data between JavaScript and Java (see Pavel's blog for more details). 

Additional resources: 

Monday Sep 15, 2014

Spotlight on GlassFish 4.1: #10 WebSocket Client Redirect

Spotlight on GlassFish 4.1' is a series of posts that highlights specific enhancements of the latest GF release, GlassFish 4.1. It could be a new feature, a fix, a behavior change, a tip, etc.

#10 WebSocket Client Redirect

A WebSocket connection is always initiated using HTTP (or HTTP/S). After a successful handshake, the HTTP connection is upgraded to a WebSocket connection using the HTTP 1.1 upgrade header.

Tyrus and GlassFish 4.1 now support HTTP 3xx Redirect handling during the WebSocket handhake phase. This feature allows a WebSocket server end-point to transparently redirect clients to another server end-point. Tyrus WebSocket client can be configured to accept to be redirected. The number of redirections allowed is also configurable (eg. to avoid infinite redirection loop).

For more details on this feature, please check this section of the Tyrus documentation.

Thursday Aug 28, 2014

Spotlight on GlassFish 4.1: #8 WebSocket Client Reconnect

Spotlight on GlassFish 4.1' is a series of posts that highlights specific enhancements of the upcoming GlassFish 4.1 release. It could be a new feature, a fix, a behavior change, a tip, etc.

#8 WebSocket Client Reconnect 

There are various libraries to improve the WebSocket capabilities of a client in the JavaScript space. WebSockHop is one of them, one of its feature is a 'automatic reconnect' facility. That's useful for JavaScript WebSocket client endpoints.

A similar capability has been introduced in Tyrus and GlassFish 4.1. A Tyrus based WebSocket client can now register a ReconnectHandler. This handler provides 2 methods (onDisconnect() and onConnectFailure()) that will greatly simplify the handling of dropped connection. Check this Client reconnect example from the Tyrus User Guide.

Additional ressources:

Thursday Aug 21, 2014

Spotlight on GlassFish 4.1: #7 WebSocket Session Throttling and JMX Monitoring

'Spotlight on GlassFish 4.1' is a series of posts that highlights specific enhancements of the upcoming GlassFish 4.1 release. It could be a new feature, a fix, a behavior change, a tip, etc.

#7 WebSocket Session Throttling and JMX Monitoring

GlassFish 4.1 embeds Tyrus 1.8.1 which is compliant with the Maintenance Release of JSR 356 ("WebSocket API 1.1"). This release also brings brings additional features to the WebSocket support in GlassFish.

JMX Monitoring:

Tyrus now exposes WebSocket metrics through JMX . In GF 4.1, the following message statistics are monitored for both sent and received messages:

  • messages count
  • messages count per second
  • average message size
  • smallest message size
  • largest message size

Those statistics are collected independently of the message type (global count) and per specific message type (text, binary and control message). In GF 4.1, Tyrus also monitors, and exposes through JMX, errors at the application and endpoint level.

For more information, please check Tyrus JMX Monitoring

Session Throttling

To preserve resources on the server hosting websocket endpoints, Tyrus now offers ways to limit the number of open sessions. Those limits can be configured at different level:

  • per whole application
  • per endpoint
  • per remote endpoint address (client IP address)

 

For more details, check Tyrus Session Throttling.

The next entry will focus on Tyrus new clients-side features.

Tuesday Aug 19, 2014

Spotlight on GlassFish 4.1: #6 Java API for WebSocket 1.1

'Spotlight on GlassFish 4.1' is a series of posts that highlights specific enhancements of the upcoming GlassFish 4.1 release. It could be a new feature, a fix, a behavior change, a tip, etc.

#6 Java API for WebSocket 1.1

JSR 356 (Java API for WebSocket) has recently passed the Maintenance Release ballot, this Maintenance Release fixes an important issue when Java SE 8 Lambdas are used (see here). GlassFish 4.1 will include an updated version of Tyrus (JSR 356 Reference Implementation) to bring the WebSocket API level to the latest version of the specification, i.e. WebSocket API for Java 1.1.

It should be mentioned that the Tyrus version included in GlassFish 4.1 also brings additional features. Some of those will be highlighted in upcoming entries.

Tuesday Jul 29, 2014

Java API for WebSocket 1.1

Java API for WebSocket (JSR 356) is going through the JCP maintenance release process as it enters today the Maintenance Review Ballot. This ballot will end in a week on August 4. 

The proposed changes are relatively limited but are nevertheless important. In the current specification (1.0), the issue is located in the Session.addMessageHandler(MessageHandler) method which is forcing implementations to get the generic type of the message handler instance. And in some cases, that approach can be problematic (e.g. with lambda based message handler).

To solve this, the 1.1 version of the JSR 356 specification introduces 2 new addMessageHandler() methods (and keep the existing method for backward compatibility). For the complete descriptions of the issue and the 2 new methods, check here.

If everything goes well (i.e. Maintenance Review Ballot passed in time), Tyrus (JSR 356 Reference Implementation) will be updated to reflect those changes and should be integrated in the upcoming GlassFish 4.1 release.

Monday Mar 24, 2014

Tyrus 1.5 released! Just in time for Java 8

1i=1njiλeλ2λ=1i=1ne(n1)λ2n1=1ne(n1)λ2n1


A new version Tyrus 1.5 (reference implementation of JSR 356 WebSockets API), was released. With it you get of course bug fixes and improvements, but most importantly a runtime fix on Java 8! And a few more things: 

 Going back to the JDK 8 issue, the good thing is that Tyrus 1.5 fixed the support of inherited annotated methods. If you are curious about this, go check Pavel Bucek's weblog post about the new Tyrus 1.5 release. Oh and if you want to know what's up with the math function above, since you are a WebSocket developer you may want to know what is the probability of two people will talk at the same time.

Cheers! 

Tuesday Jan 28, 2014

Using updated release of Jersey, Tyrus, Weld, ... in GlassFish 4

The Java EE specification is an umbrella specification that refers to different components specifications, aka components JSRs (e.g. Servlet, JMS, JAX-RS, ...). And as the Java EE 7 Reference Implementation, GlassFish 4 is made of those different components JSRs Reference Implementations. 

In addition to the specification, most of those implementations (eg. Jersey) also offers additional features (and fixes). And clearly, the different implementations that make GlassFish are evolving each at a different pace. Jersey (JAX-RS RI), Tyrus (WebSocket RI), Weld (CDI RI), Mojarra (JSF RI) are examples of implementations that evolves rapidly. GlassFish 4.0 embeds Tyrus 1.0, Jersey 2.0, Mojarra 2.2.0 and Weld 2.0.0.SP1 but since that time, those implementations have evolved quite a lot. As of today, the current release of Tyrus is 1.4, the current release of Jersey is 2.5.1, the current release of Weld is 2.0.5 and the current release of release of Mojarra is 2.2.5.

So what to do if you want to use one of the new features provided by one of those implementations in GlassFish 4? One way is to wait that the specific version of that implementation, say Jersey for example, is integrated in a nightly build of the GF 4.0.1 branch. Another solution is to upgrade the specific implementation (e.g. Jersey) in an existing GlassFish 4 setup. The following posts explains how to update Tyrus, how to update Jersey, how to update Weld and how to update Mojarra in a GF4 setup. 

It should be mentioned that no extra testing has been done, so clearly do not do this in any critical environments. And if the updated setup is not stable, it is always easy to come back to the initial configuration. Most of the time, it's just a matter of putting back the original implementation Jar and restarting GlassFish. For Jersey, the provided update script is able to restore the initial configuration if needed. 
Also, since Jersey has dependencies on HK2 and since HK2 has been updated between GF 4.0 and the 4.0.1 branch, it is only possible to update Jersey in a GlassFish 4.0.1 build.

In any cases, if you are using GF 4 with an updated version of Tyrus, Jersey, Mojarra or Weld, we would like to hear your feedback!

Monday Jan 27, 2014

Tyrus/WebSocket Client on Android

At JavaOne San Francisco 2013 Ryan Cuprak, Bala Muthuvarathan and I presented a full-house session titled Android and iOS Development with Java EE 7. Ryan is the leader of the Connecticut JUG, a close friend and my co-author on the upcoming second edition of EJB 3 in Action. Bala is a friend and former colleague from CapTech Consulting. We picked the topic as we thought there was surprisingly little content on the topic despite the fact that many people use JAX-RS/Java EE as a mobile back-end platform today and Java EE 7 is an even stronger candidate for this development model. You can check out video for the event below. The demo code for the session is available on GitHub and the slide deck is available on SlideShare. One of the surprising things we came across is that Android still has very weak support for WebSocket development. As a result, I thought it would be great if the WebSocket client APIs standardized in Java EE 7 would work on Android, so I entered a JIRA issue against Tyrus asking for such support.

Some of you might be very pleasantly surprised that the Tyrus team actually addressed the issue! You can read the details of the initial work on Pavel Bucek's blog, including a sample application. If you find the feature useful, I would encourage you to explore the work further, share your thoughts on the Tyrus mailing list or via JIRA. You could even contribute to the sample code for the JavaOne talk :-) (currently the code uses the Autobahn Android library).

Thursday Jan 09, 2014

Some Tyrus updates


Project Tyrus is the JSR 356 (Java API for WebSocket) Reference Implementation. As JSR 356 is part of Java EE 7 (Web Profile and the Full Java EE Platform), Tyrus is embedded in GlassFish 4. In addition, Tyrus *should* also run on any Servlet 3.1 compatible container.

Tyrus 1.0 was released mid 2013 when the JSR 356 specification went final. Since then, the work on Tyrus hasn't stopped and this is also true for other implementations such as Jersey for JAX-RS, Mojarra for JavaServer Faces, etc. For example, no less than 2 updates of Mojarra were released this week (2.2.5 & 2.1.27) but more on JSF later and back to Tyrus...

Here are some of features and improvments that were recently added to Tyrus :

Wednesday Dec 18, 2013

Want to Work on WebSocket/Tyrus? Oracle is Hiring!

The WebSocket team at Oracle is looking for another key contributor! If you want to become part of the dynamic, high-profile team that is working on the industry leading Java API for WebSocket (JSR 356) reference implementation Tyrus and related open standards, projects and products like Java EE, GlassFish and WebLogic, this is the time to update your resume/CV and share it with us. The job is based in Prague, Czech Republic.

The formal details of the job are on LinkedIn.

If you are interested and have any questions, please feel free to post your questions here, get in touch with the Tyrus team or drop an email directly to pavel dot bucek at oracle dot com.

Friday Nov 22, 2013

Optimized WebSocket broadcast

"When you have to make a choice and don't make it, that is in itself a choice."  (William James)  Tyrus logo

The Java API for WebSocket (JSR 356) is one of the API added to Java EE 7. It is a '1.0' release, that means that the API is complete and fully functional. It is often said that premature optimisation is the root of all evil, so an initial implementation can easily be optimised. The same is also true for features, choices had to made as it is impossible to implement all the desired features in an initial release. Clearly, they are different aspects that could easily be improved going forward.

Tyrus serves as the JSR 356 Reference Implementation, it is also a test-bed for potential new WebSocket features and improvements. As always, a proprietary feature of an implementation doesn't necessarily means that this particular feature will be included in a future revision of the specification. It could just remains a proprietary feature or an implementation specific optimisation.

In this post, Pavel Bucek, a Tyrus team member, discuss how a WebSocket Server Endpoint could be improved when it needs to broadcast a message to its connected remote endpoints. In Tyrus 1.3, a new broadcast() method has been introduced, it allows to broadcast a message by re-using the same data frame for all the remote endpoints, by doing so the overall performance should be improved.


Wednesday Nov 13, 2013

Tyrus 1.3 Released

Tyrus, the WebSocket 1.0 reference implementation included in GlassFish and WebLogic, released version 1.3 a few days ago. The release contains some valuable features like asynchronous handling of the client-side connectToServer method call, optimized broadcast support and lots of stability and performance improvements (listed below).

One issue that popped up a little too late for getting into 1.3 is TYRUS-263: Accessing SSL protected resource via HTTP proxy. This regression is already fixed in the Tyrus master branch, please let us know whether you consider this feature critical. It might be possible to release 1.3.1 just with this fix.

Tyrus 1.3 is already integrated into GlassFish trunk, so is included in the nightly releases. You can also just remove all tyrus related jars and replace it with the contents of the websocket-ri-archive artifact.

Below is a list of JIRA entries incorporated into Tyrus 1.3:

  • TYRUS-71: ErroCollector not properly used in AnnotatedEndpoint class.
  • TYRUS-262: @OnOpen fails for programmatically deployed annotated endpoint.
  • TYRUS-261: Text decoder disables Binary decoder if both are configured for the same server endpoint; endpoint cannot receive binary messages anymore.
  • TYRUS-248: Consolidate Extension representation
  • TYRUS-258: Tyrus always creates HTTP session
  • TYRUS-251: DecodeException is not passed to @OnError method
  • TYRUS-252: encoder for primitive types cannot be overridden
  • TYRUS-250: Sec-WebSocket-Protocol header cannot be present when there is no negotiated subprotocol
  • TYRUS-249: WebSocketContainer MaxSessionIdleTimeout is not propagated to Session (server side)
  • TYRUS-257: Async timeout value set on WebSocketContainer is not propagated to RemoteEndpoints (Session#getAsyncRemote())
  • TYRUS-253: DecodeException is not passed to @OnError method from session.getAsyncRemote().sendObject
  • TYRUS-243: WebSocketContainer.connectToServer can block for seconds
  • TYRUS-227: Build failure : AsyncBinaryTest
  • TYRUS-226: Tyrus build error : OnCloseTest
  • TYRUS-247: Make all samples use TestContainer for tests
  • TYRUS-238: Refactor WebSocketEngine (SPI and Impl)
  • TYRUS-157: Submitting tasks to an injected ManagedExecutorService in a ServerEndpoint does not work
  • TYRUS-137: Improve subprotocols/extensions headers parsing
  • TYRUS-133: Some Broadcast(er) API is needed in order to opmtimize chat-like usecases
  • TYRUS-245: ServerEndpointConfig#getConfiigurator returns Configurator not used when getNegotiatedExtensions has been called
  • TYRUS-240: clean up duplicated static fields (strings)
  • TYRUS-230: When Session is invalidated, the close reason is not 1006
  • TYRUS-190: Remove TyrusServetServerContainer (merge with TyrusServerContainer)
  • TYRUS-65: Implement common utilities for testing
  • TYRUS-242: Tyrus does not run on JDK8 compact2 profile
  • TYRUS-237: RemoteEndpoint.Async#sendBinary does not throw IllegalArgumentException when data is null
  • TYRUS-239: Improve WebSocketEngine ByteBuffer handling
  • TYRUS-232: Refactor grizzly/servlet container – Tyrus-SPI
  • TYRUS-235: Fix findbugs errors in tests/servlet
  • TYRUS-234: Remove support for older protocol version
  • TYRUS-229: Session#setMaxIdleTimeout() will kill the session whether or not the session actually timed out
  • TYRUS-225: Invalidation of (Servlet) HttpSession does not invalidate WebSocket Session
  • TYRUS-153: Static map in TyrusRemotEndpoint
  • TYRUS-201: Wrong ServletInputStream#isReady() usage in TyrusHttpUpgradeHandler
  • TYRUS-224: Refactor Connection#write and ConnectionImpl to use CompletionHandler only (no Future)
  • TYRUS-221: wss:// doesn’t appear to function correctly via a http proxy
  • TYRUS-146: Support request from client to secured services (“wss”)
  • TYRUS-223: Message can be writen multiple times when running on Servlet container

Besides trying the release out, you should feel equally free to file new JIRA entries on Tyrus and the rest of the GlassFish codebase for that matter.