Hi,
every new comnection creates new guacd connection, which means new VNC
connection. You need to create some kind of lookup map so when new user
tries to connect, either new connection is established or existing one is
used.

The trickier part are race conditions,so synchronizing access to the lookup
table is the key, especially when removing the connection and handling
disconnects.


Hope it helps a bit.


Best Regards,
Lukas

Dne st 8. 6. 2022 15:04 uživatel Frco. Javier Rial <fjr...@gmail.com>
napsal:

> Hi all
>
> I'm having this same exact problem as describe this
> https://stackoverflow.com/questions/54374533/guacamole-multiple-simultaneous-vnc-connections-over-websocket-close-each-other
>
> I've built my own guacamole application, just like this (I'm omitting the
> keycloak integration for authentication that I have and some minor details)
> My app has an angular frontend, a backend in Java and a docker server.
>
> Basically, when an user connects to the httptunnel/websocket, the backend
> in java connects to the docker server (using docker api) to setup and run
> an specific docker image for this user. This image contains the guacd
> daemon running inside
>
> Just to clarify, if I use HTTPTunnel, it works fine. I have my own
> implementation for the httptunnel in the java backend and works without any
> issues handling several connected users, but, with the poor performance
> provided by the httptunnel
>
> While using the websocket implementation in java, I have the mentioned
> problem in stackoverflow
>
> My implementation is as follows (minimal code provided here)
> @ServerEndpoint(value = "/webSocket", configurator =
> CustomSpringConfigurator.class)
> @Component
> public class WebSocketTunnel extends GuacamoleWebSocketTunnelEndpoint {
>
>     @Autowired
>     private DefaultConfiguration defaultConfiguration;
>
>     @Autowired
>     private ContainerService containerService;
>
>     @Autowired
>     private UserUtil userUtil;
>
>     @Override
>     protected GuacamoleTunnel createTunnel(Session session, EndpointConfig
> endpointConfig) throws GuacamoleException {
>
>         try {
>             GuacamoleSocket socket = null;
>    containerService.getContainer(principalTO.get().getIdUser());
>             socket = new ConfiguredGuacamoleSocket(
>                 new InetGuacamoleSocket(containerTO.get().getHost(),
>
> Integer.parseInt(containerTO.get().getPort())),configuration);
>                     }
>                 }
>             GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
>             return tunnel;
>         } catch (Exception e) {
>             log.error(e);
>         }
>         return null;
>     }
>
>     .....
> }
>
>
> The angular frontend just connects to the java backend endpoint that
> creates the websocket and gets the tunnel provided.
>
> The socket is configured against the IP/port of the running docker image
> on the docker server
> It returns the websocket and everything works fine with one connected
> user. Each running docker image has it's own ip and different ports binded
> externally for the guacd daemon (internally all guacd listen on the same
> port 4822)
>
> But as soon as any other user tries to connect, the websocket is closed
>
> This is logged in the java backend
>
> Exception in thread "Thread-2" java.lang.IllegalStateException: The
> WebSocket session [1] has been closed and no method (apart from close())
> may be called on a closed session
> at org.apache.tomcat.websocket.WsSession.checkState(WsSession.java:1082)
> at
> org.apache.tomcat.websocket.WsSession.getUserProperties(WsSession.java:990)
> at
> org.apache.tomcat.websocket.WsRemoteEndpointImplBase.getBlockingSendTimeout(WsRemoteEndpointImplBase.java:533)
> at
> org.apache.tomcat.websocket.WsRemoteEndpointImplBase.getTimeoutExpiry(WsRemoteEndpointImplBase.java:270)
> at
> org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:244)
> at
> org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendString(WsRemoteEndpointImplBase.java:195)
> at
> org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:37)
> at
> org.apache.guacamole.websocket.GuacamoleWebSocketTunnelEndpoint.sendInstruction(GuacamoleWebSocketTunnelEndpoint.java:152)
> at
> org.apache.guacamole.websocket.GuacamoleWebSocketTunnelEndpoint.access$200(GuacamoleWebSocketTunnelEndpoint.java:53)
> at
> org.apache.guacamole.websocket.GuacamoleWebSocketTunnelEndpoint$2.run(GuacamoleWebSocketTunnelEndpoint.java:253)
>
>
> Can someone give me any hint about the websocket implementation ??
> Please, feel free to ask me for anything
>
>

Reply via email to