vadimpronin / guacamole-lite

Node.js library for creating Guacamole-compatible servers. Guacamole is a RDP/VNC/SSH/Telnet client for HTML5 browsers.
Apache License 2.0
250 stars 78 forks source link

How to use guacamole-lite from the frontend ? #26

Open MeriemBo opened 5 years ago

MeriemBo commented 5 years ago

I'm trying to use this from my angular app , running on port 4200 in order to connect to an external desktop running on a given IP address. Here's the code I could achieve for that purpose so far :

import { Component, OnInit } from '@angular/core';
import { RemoteDesktopManager } from '@illgrenoble/ngx-remote-desktop';
import { WebSocketTunnel } from '@illgrenoble/guacamole-common-js';
import { Guacamole } from 'guacamole-common-js';
import { GuacamoleLite } from 'guacamole-lite';
  @Component({
   selector: 'app-rdp',
   templateUrl: './rdp.component.html',
   styleUrls: ['./rdp.component.scss']
   })
  export class RDPComponent implements OnInit {

  private manager: RemoteDesktopManager;
  ngOnInit() {
    // Setup tunnel. The tunnel can be either: WebsocketTunnel, HTTPTunnel or ChainedTunnel
    const tunnel = new WebSocketTunnel('ws://localhost:4200');
    const client = new Guacamole.Client(tunnel);
    document.body.appendChild(client.getDisplay().getElement());
    /**
     *  Create an instance of the remote desktop manager by 
     *  passing in the tunnel and parameters
     */
    this.manager = new RemoteDesktopManager(tunnel);
          // URL parameters (image, audio and other query parameters you want to send to the tunnel.)
    const parameters = {
        ip: '120.160.10.149',
        port : 5000,
        type: 'rdp',
        image: 'image/png',
        width: window.screen.width,
        height: window.screen.height,
        username:'username',
        password :'0000'

    };
    this.manager.connect(parameters);
    console.log('tunnel state'+this.manager.getState());
    console.log('Disconnected state'+RemoteDesktopManager.STATE.DISCONNECTED);
}

}

In my console I keep getting this error : eror

I'm new to this and I don't know what am I missing . any help provided will be good. thank you

ankitmhn commented 4 years ago

Did you find a solution to this?

eglove commented 2 years ago

I get either the Client doesn't exist or WebSocketTunnel is not a function or constructor. (Depending on how to try to use it.)

MarkSpencerTan commented 2 years ago

I think it's how you're importing the Guacamole client on the top. Try this instead:

import Guacamole from 'guacamole-common-js';
Harsh4999 commented 2 years ago

What is the solution to this I am too stuck here