You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@guacamole.apache.org by "AJ Funk (Jira)" <ji...@apache.org> on 2020/04/07 05:57:00 UTC

[jira] [Updated] (GUACAMOLE-1015) tunnel and websocket states out of sync

     [ https://issues.apache.org/jira/browse/GUACAMOLE-1015?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

AJ Funk updated GUACAMOLE-1015:
-------------------------------
    Description: 
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.

  was:
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.


> 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)