Community
Participate
Working Groups
When an application context is stopped (or stopped and restarted which is what happens on redeploy), WebSocket connections should be closed, and currently they are not. The reason is that WebSocket connections are stateful (differently from Http connections that are stateless), so they have a context that cannot be reused across restarts.
Fixed by making WebSocketFactory extends AbstractLifeCycle, and tracking WebSocketServletConnections. When WebSocketFactory is stopped, connections are closed with code 1001 (close_shutdown). The same has been made for WebSocketClientFactory: connections are now tracked and when it's stopped, connections are closed with code 1001. In both cases, connections are tracked using a ConcurrentLinkedQueue. Addition to the queue is done before invoking application callbacks such as onOpen(), and only if the factory is running. Removal from the queue piggybacks on the Connection.onClose() callback, that is invoked by the I/O layer when a connection is closed. When the factory is being stopped, no additions are possible, and only removals or iteration over connections may be concurrent. Closing a connection that is already closed is a no-op, so we're safe.