You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by "McRoy, Jeffrey (GE Healthcare)" <Je...@ge.com> on 2018/02/16 22:46:59 UTC

Working with pipes

Hi Everyone,

 

I’m looking at how pipes work with the Guac client. For example…

.

.

// Instantiate client, using an HTTP tunnel - tenet connection

var guac = new Guacamole.Client(

new Guacamole.HTTPTunnel("tunnel")

 );

var stream = guac.createPipeStream("text/plain", "response");

.

.

guac.onpipe = function(input_stream, mimetype, name) {

console.log("onpipe");

if (name == "response") {

reader = new Guacamole.StringReader(input_stream);

reader.ontext = function receiveText(text) {

console.log(text);

};

}

}

.

.

 

The client makes a successful telnet connection and the I’m able to use it. However, I never see anything echoed to the Javascript console. I’m fairly sure onpipe is supposed to fire whenever a pipe is created. In my example it seems like onpipe does not execute. Is this the correct usage?

 

Thanks & Regards,

Jeff

 


Re: Working with pipes

Posted by Mike Jumper <mi...@guac-dev.org>.
On Fri, Feb 16, 2018 at 2:46 PM, McRoy, Jeffrey (GE Healthcare) <
Jeffrey.McRoy@ge.com> wrote:

> Hi Everyone,
>
>
>
> I’m looking at how pipes work with the Guac client. For example…
>
> .
>
> .
>
> // Instantiate client, using an HTTP tunnel - tenet connection
>
> var guac = new Guacamole.Client(
>
> new Guacamole.HTTPTunnel("tunnel")
>
> );
>
> var stream = guac.createPipeStream("text/plain", "response");
>
> .
>
> .
>
> guac.onpipe = function(input_stream, mimetype, name) {
>
> console.log("onpipe");
>
> if (name == "response") {
>
> reader = new Guacamole.StringReader(input_stream);
>
> reader.ontext = function receiveText(text) {
>
> console.log(text);
>
> };
>
> }
>
> }
>
> .
>
> .
>
>
>
> The client makes a successful telnet connection and the I’m able to use
> it. However, I never see anything echoed to the Javascript console. I’m
> fairly sure onpipe is supposed to fire whenever a pipe is created. In my
> example it seems like onpipe does not execute. Is this the correct usage?
>
>
>

Nope. There is a distinction between createPipeStream() and onpipe:

createPipeStream() creates an outbound pipe stream from client to server.
It sends a "pipe" instruction [1] declaring the stream with the parameters
given, and the handlers of that stream object will be invoked in response
to instructions received from the server. Data ("blob" instructions [2]) is
sent strictly from client to server. In this case, as the telnet protocol
support does not attempt to handle inbound pipe streams, this will most
likely result in an "ack" [3] with an associated error code, implicitly
closing the stream. If the code you've provided here is exactly what you
are doing, it's also likely that doing this has no real effect, since the
tunnel will not be open at the time that the "pipe" instruction needs to be
sent, and the outbound instruction will simply be dropped by the tunnel
implementation.

The onpipe handler, on the other hand, is invoked in response to an
*inbound* pipe stream from server to client. This occurs when a "pipe"
instruction is sent by the server. It will not be invoked as a direct
result of functions that you call on the client-side; this and other
handlers on the Guacamole.Client object deal only with received Guacamole
instructions.

- Mike

[1]
http://guacamole.apache.org/doc/gug/protocol-reference.html#pipe-instruction
[2]
http://guacamole.apache.org/doc/gug/protocol-reference.html#blob-instruction
[3]
http://guacamole.apache.org/doc/gug/protocol-reference.html#ack-instruction