guacamole common multiple sessions

140 Views Asked by At

I am using the guacamole common library in a spring boot application with an angular frontend. We create the vnc tunnels over an endpoint extending the GuacamoleHTTPTunnelServlet. We built the start application according to this guide and extended it now according to our needs.

It currently works fine, the problem is as soon as a user reloads or leaves and re-enters the webpage with the vnc tunnel integrated. So it seems that there is a conflict with the tunnel sessions for a user. How can I properly manage these sessions? Is there an example somewhere? I think a tokenbased approach can solve this issue - I gave it already a try but I have problems with persisting these GuacamoleTunnel objects.

This is my controller method:

@Override
  protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException {
    String user = request.getUserPrincipal().getName();
    LOGGER.info("Creating tunnel for user {}.", user);

    if (tunnelSessionManager.getTunnel(user) != null) {
      // If a tunnel already exists for the user, close it
      LOGGER.trace("Tunnel already exists for user {}. Closing tunnel.", user);
      tunnelSessionManager.closeTunnel(user);
    }

    GuacamoleConfiguration config = prepareConfiguration(request);

    try {
      // Connect to guacd, proxying a connection to the VNC server above
      GuacamoleSocket socket = connectToGuacD(config);

      // Create tunnel from now-configured socket
      SimpleGuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
      // Associate the tunnel with the user's id
      tunnelSessionManager.associateTunnel(user, tunnel);

      return tunnel;
    } catch (GuacamoleException e) {
      LOGGER.error("Error while creating tunnel.", e);
      return null;
    }
  }
0

There are 0 best solutions below