code: @Override
      public void sessionClosed(IoSession session) throws Exception {
          log.trace("Session {} closed", session.getId());
          // remove connection from scope
          WebSocketConnection conn = (WebSocketConnection) session.removeAttribute(Constants.CONNECTION);
          if (conn != null) {
              // remove from the manager
              WebSocketPlugin plugin = (WebSocketPlugin) PluginRegistry.getPlugin("WebSocketPlugin");
              if (plugin != null) {
                  String path = conn.getPath();
                  if (path != null) {
                      WebSocketScopeManager manager = (WebSocketScopeManager) session.removeAttribute(Constants.MANAGER);
                      if (manager == null) {
                          manager = plugin.getManager(path);
                      }
                      if (manager != null) {
                          manager.removeConnection(conn);
                      } else {
                          log.debug("WebSocket manager was not found");
                      }
                  } else {
                      log.debug("WebSocket connection path was null");
                  }
              } else {
                  log.debug("WebSocket plugin was not found");
              }
          } else {
              log.debug("WebSocket connection was null");
          }
          super.sessionClosed(session);
      }
docs: {@inheritDoc}