You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by messido <mo...@gmail.com> on 2018/04/23 23:45:42 UTC

Guacd terminates connection if idle for ~30 seconds

Long story short; connection to host through guacd is working perfectly
fine.. I'm using my own client to connect to guacd.. however if the "user"
does not move the mouse/keyboard for ~30 seconds (idling) guacd will
automatically terminate connection and log "ERROR: User is not responding".

Is there a way to extend the timer? I'm assuming it's some type of session
timeout? Even though connection is successfully created.



--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Guacd terminates connection if idle for ~30 seconds

Posted by Mike Jumper <mi...@guac-dev.org>.
On Tue, Apr 24, 2018 at 4:16 PM, messido <mo...@gmail.com> wrote:

> Okay so after trying multiple things out, I have come to some conclusions.
>
> 1) If i test locally, works fine and no disconnect happens
> 2) Only difference between my server and local machine is that server has
> SSL setup, am i supposed to be adding the key and cert into guac.conf?


No, you don't need to touch guacd.conf to configure SSL.

If your server already has SSL configured, then that's really all you need
to do. Assuming you've done this through a reverse proxy, you need to
configure your proxy to not buffer responses:

http://guacamole.apache.org/doc/gug/proxying-guacamole.html

Or is that only if i'm using the guacamole-client
>
>
You are using guacamole-client. Even if you are building your own webapp
using the APIs, those APIs (guacamole-common and guacamole-common-js) are
parts of guacamole-client.

3) this.tunnel.connect(...) throws error on both local machine and server..
>

This statement doesn't make sense. The function "tunnel.connect()" runs
locally within the browser. Any error which it receives from the server
will be passed to tunnel.onerror, not thrown. If the server encounters an
error, that error is passed along in the HTTP (or WebSocket) response,
received by the client (browser), and ultimately translated into a
Guacamole.Status object and passed to tunnel.onerror.

catching error with "tunnel.onerror" throws an object with pretty much no
> information.. error.code = NaN, error.isError =
> Guacamole.Status/this.isError(), error.message = null..
>
>
Are you sure you're using the latest versions of both guacamole-common and
guacamole-common-js?

- Mike

Re: Guacd terminates connection if idle for ~30 seconds

Posted by messido <mo...@gmail.com>.
Okay so after trying multiple things out, I have come to some conclusions. 

1) If i test locally, works fine and no disconnect happens
2) Only difference between my server and local machine is that server has
SSL setup, am i supposed to be adding the key and cert into guac.conf? Or is
that only if i'm using the guacamole-client

3) this.tunnel.connect(...) throws error on both local machine and server..
catching error with "tunnel.onerror" throws an object with pretty much no
information.. error.code = NaN, error.isError =
Guacamole.Status/this.isError(), error.message = null.. 

4) Running guacd on trace log level, I see that every frame gets a "User
confirmation of frame XXXX" when running on my localmachine, but on my
server I only get the "Server completed frame XXX" with no user
confirmations (unless keyboard/mouse is moved)... 

Appreciate your continued responses, Mike!




--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Guacd terminates connection if idle for ~30 seconds

Posted by Mike Jumper <mi...@guac-dev.org>.
On Tue, Apr 24, 2018 at 1:51 AM, messido <mo...@gmail.com> wrote:

> Mike Jumper wrote
> > Why are you manually invoking sendMessage()?
>
> Well i'm creating an interval to keep checking if connection is alive,
>

You do not need to do this. Ensuring keep-alive pings are sent during the
connection is an internal concern of Guacamole.Client, and the
Guacamole.Client already does this automatically. The snippet of code I
referenced earlier was not meant as a suggestion of what you need to do,
but rather to demonstrate that Guacamole.Client already takes this into
account, and that the cause of the timeout you're seeing must be something
else.

here's the code
>
> tunnel: any = new Guacamole.HTTPTunnel('tunnel');
>   guac: any  = new Guacamole.Client(this.tunnel);
>
> try {
>       this.tunnel.connect('tunnel');
>       console.log('connected tunnel');
>     }catch(err){
>       console.log('error connecting to tunnel', err)
>       throw err;
>     }
>

Please take a look at the tutorial in the manual, as well as the custom
webapp example included in the source:

http://guacamole.apache.org/doc/gug/writing-you-own-guacamole-app.html
https://github.com/apache/guacamole-client/tree/master/doc/guacamole-example

Though errors during connect were at one time handled synchronously, this
has not been the case since roughly 0.9.0 [1]. You will need to provide a
handler for "onerror" to programmatically deal with an error returned by
your server.

I would recommend looking into using the WebSocket tunnel, as well, at some
point (presumably chained behind the HTTPTunnel using ChainedTunnel), but
let's figure out what's wrong with your HTTP tunnel first.

Mike Jumper wrote
> > If your tunnel is returning HTTP 500, you will need to look at the
> > server-sode code of your tunnel implementation. Running it under a
> > debugger
> > may be in order.
> >
> > - Mike
>
> I'm reading the logs from guacd with DEBUG level on, nothing different is
> being thrown when calling "this.tunnel.connect(...);" vs when not calling
> it.. and the try/catch around "this.tunnel.connect" is not catching an
> error.. Should I be reading through trace or is there a better way to
> narrow
> down the issue on why tunnel.connect isn't working?
>

I'm referring here to your tunnel implementation (the class you've written
in your custom guac-powered webapp which extends
GuacamoleHTTPTunnelServlet). An HTTP 500 is returned by Tomcat, and thus by
the servlet handling the tunnel, not by guacd. If your web application is
returning an HTTP 500, you will need to debug your web application.

- Mike

[1]
https://github.com/apache/guacamole-client/commit/627271953d6eee6f49f4a385d8de62d6a0098be5

Re: Guacd terminates connection if idle for ~30 seconds

Posted by messido <mo...@gmail.com>.
Mike Jumper wrote
> Why are you manually invoking sendMessage()?

Well i'm creating an interval to keep checking if connection is alive,
here's the code

tunnel: any = new Guacamole.HTTPTunnel('tunnel');
  guac: any  = new Guacamole.Client(this.tunnel);

try {
      this.tunnel.connect('tunnel');
      console.log('connected tunnel');
    }catch(err){
      console.log('error connecting to tunnel', err)
      throw err;
    }
    //ensures connection is alive
    window.setInterval(() => {
      console.log('sending ping');
      this.tunnel.sendMessage('nop');
    }, 5000);




Mike Jumper wrote
> If your tunnel is returning HTTP 500, you will need to look at the
> server-sode code of your tunnel implementation. Running it under a
> debugger
> may be in order.
> 
> - Mike

I'm reading the logs from guacd with DEBUG level on, nothing different is
being thrown when calling "this.tunnel.connect(...);" vs when not calling
it.. and the try/catch around "this.tunnel.connect" is not catching an
error.. Should I be reading through trace or is there a better way to narrow
down the issue on why tunnel.connect isn't working?




--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Guacd terminates connection if idle for ~30 seconds

Posted by Mike Jumper <mi...@guac-dev.org>.
On Mon, Apr 23, 2018, 19:47 messido <mo...@gmail.com> wrote:

> I'm getting error 500 when trying to run "tunnel.connect();".. what exactly
> is it expecting of the data param inside the "connect()" function?
>

It is arbitrary data, dictated only by your tunnel implementation.

The way i previous had my client being setup is
>
> guac: any  = new Guacamole.Client(new Guacamole.HTTPTunnel('tunnel'));
>
> but now since I need a tunnel in order to call the sendMessage function I
> split it into
>

Why are you manually invoking sendMessage()?

...
> so now I figured I need to "connect" the tunnel as well, in order to be
> able
> to "sendMessage".. but tunnel throws error 500 when trying to connect.. is
> it expecting the UUID or what? All the API says is "The data to send to the
> tunnel when connecting."


If your tunnel is returning HTTP 500, you will need to look at the
server-sode code of your tunnel implementation. Running it under a debugger
may be in order.

- Mike

Re: Guacd terminates connection if idle for ~30 seconds

Posted by messido <mo...@gmail.com>.
I'm getting error 500 when trying to run "tunnel.connect();".. what exactly
is it expecting of the data param inside the "connect()" function?

The way i previous had my client being setup is 

guac: any  = new Guacamole.Client(new Guacamole.HTTPTunnel('tunnel'));

but now since I need a tunnel in order to call the sendMessage function I
split it into

tunnel: any = new Guacamole.HTTPTunnel('tunnel'));
guac: any  = new Guacamole.Client(this.tunnel);

so now I figured I need to "connect" the tunnel as well, in order to be able
to "sendMessage".. but tunnel throws error 500 when trying to connect.. is
it expecting the UUID or what? All the API says is "The data to send to the
tunnel when connecting."

Sorry for multiple follow-up questions




--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Guacd terminates connection if idle for ~30 seconds

Posted by messido <mo...@gmail.com>.
Mike Jumper wrote
> No, there are other messages exchanged besides keyboard and mouse events.
> In addition to sync responses (client acknowledgement of frame rendering),
> there is a "nop" keep-alive sent every 5 seconds:
> 
> https://github.com/apache/guacamole-client/blob/57d81544ea46fc4f7e68836d146ca60022c430fa/guacamole-common-js/src/main/webapp/modules/Client.js#L1506-L1509

That's exactly what I am looking for, appreciate your time




--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Guacd terminates connection if idle for ~30 seconds

Posted by Mike Jumper <mi...@guac-dev.org>.
On Mon, Apr 23, 2018, 17:39 messido <mo...@gmail.com> wrote:

> Thanks for the quick response..
>
> Yes that's correct, I am referring to a web application built off
> gucamole-common-js..
>
> Going with debug level = trace (for guacd), I can see that guacd is
> awaiting
> a "confirmation" from the user in order to keep connection alive..


No, it isn't waiting for confirmation from the user. It is waiting for any
messages of any kind from the client.

now if no
> mouse/keyboard movements are sent, guacd will not receive a confirmation
> which will terminate the connection after what i'm assuming is 15 - 30
> seconds..
>

No, there are other messages exchanged besides keyboard and mouse events.
In addition to sync responses (client acknowledgement of frame rendering),
there is a "nop" keep-alive sent every 5 seconds:

https://github.com/apache/guacamole-client/blob/57d81544ea46fc4f7e68836d146ca60022c430fa/guacamole-common-js/src/main/webapp/modules/Client.js#L1506-L1509


is there a way to send confirmations back to guacd even if the user does not
> move mouse/keyboard?
>

This already happens automatically (see above). If your connection is
timing out, it must be for a different reason.

Unless you have made changes to the internals of the client, the most
likely cause would be network disruption, such as a proxy between the user
and the server.

The user does not need to continuously move the mouse, press keys, etc.
(which would make things fundamentally unusable). Simply having the
connection open is sufficient.

- Mike

Re: Guacd terminates connection if idle for ~30 seconds

Posted by messido <mo...@gmail.com>.
Thanks for the quick response..

Yes that's correct, I am referring to a web application built off
gucamole-common-js.. 

Going with debug level = trace (for guacd), I can see that guacd is awaiting
a "confirmation" from the user in order to keep connection alive.. now if no
mouse/keyboard movements are sent, guacd will not receive a confirmation
which will terminate the connection after what i'm assuming is 15 - 30
seconds..

is there a way to send confirmations back to guacd even if the user does not
move mouse/keyboard? 



--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

Re: Guacd terminates connection if idle for ~30 seconds

Posted by Mike Jumper <mi...@guac-dev.org>.
On Mon, Apr 23, 2018 at 4:45 PM, messido <mo...@gmail.com> wrote:

> Long story short; connection to host through guacd is working perfectly
> fine.. I'm using my own client to connect to guacd.. however if the "user"
> does not move the mouse/keyboard for ~30 seconds (idling) guacd will
> automatically terminate connection and log "ERROR: User is not responding".
>
> Is there a way to extend the timer? I'm assuming it's some type of session
> timeout? Even though connection is successfully created.
>
>
That timeout actually does not deal with user mouse/keyboard interaction.
On a healthy connection, the Guacamole client will be exchanging messages
back and forth with the server every few seconds. If something disrupts
that communication for 15+ seconds, then guacd will summarily close the
connection.

When you say your "own client", what are you referring to specifically? A
web application built off guacamole-common-js, etc.?

- Mike