[ 
https://issues.apache.org/jira/browse/GUACAMOLE-1015?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17087120#comment-17087120
 ] 

Nick Couchman commented on GUACAMOLE-1015:
------------------------------------------

I'm not sure this is a bug in Guacamole, mainly because this issue does not 
show up in Guacamole Client.  Perhaps you are expected to do something in your 
custom application code to keep these individual components in sync?

> tunnel and websocket states out of sync
> ---------------------------------------
>
>                 Key: GUACAMOLE-1015
>                 URL: https://issues.apache.org/jira/browse/GUACAMOLE-1015
>             Project: Guacamole
>          Issue Type: Bug
>          Components: guacamole-common-js
>    Affects Versions: 1.1.0
>            Reporter: AJ Funk
>            Priority: Minor
>
> When using the WebSocketTunnel, we are constantly seeing the error: 
> "InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in 
> CONNECTING state." being thrown.
> The identify the issue, we added some extra logging information by overriding 
> the sendMessage method and wrapping it with a try/catch like this:
> {code:java}
> const websocketTunnel = this.websocket = new 
> Guacamole.WebSocketTunnel(`wss://${domain}/guacamole/${guacWsPort}`);
> const guac = this.rfb = new Guacamole.Client(this.websocket);
> // wrap sendMessage with a try/catch for debugging
> const originalTunnelSendMessage = websocketTunnel.sendMessage;
> this.websocket.sendMessage = (...args) => {
>   try {
>     originalTunnelSendMessage.apply(this.websocket, args);
>   } catch (e) {
>     if (window.Sentry) {
>       const clientState = guac.getState();
>       const tunnelState = websocketTunnel.state;
>       const socketState = websocketTunnel.socket.readyState;
>       window.Sentry.withScope(scope => {
>         scope.setTag("origin", "guac socket");
>         scope.setExtra("args", args);
>         scope.setExtra("clientState", clientState);
>         scope.setExtra("tunnelState", tunnelState);
>         scope.setExtra("socketReadyState", socketState);
>         window.Sentry.captureException(e);
>       });
>     }
>   }
> }
> {code}
> (we use [https://sentry.io|https://sentry.io/] to capture exceptions)
> This provided the following values:
>  clientState: 2 (STATE_WAITING)
>  tunnelState: 3 (UNSTABLE)
>  socketReadyState: 0 (CONNECTING)
>  We managed to apply a patch to silence this error. On this line 
> [https://guacamole.apache.org/doc/1.1.0/guacamole-common-js/Tunnel.js.html#line379]
> we changed
> {code:java}
> if (!tunnel.isConnected()){code}
> to check the socket's state instead of the tunnel's:
> {code:java}
> if (!socket || socket.readyState !== WebSocket.OPEN ){code}
>  
> We determined that this error was non-critical since it did not disrupt the 
> client's websocket connection, but it caused a lot of noise with thousands of 
> error events.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to