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: