ILLGrenoble / ngx-remote-desktop

Angular component for accessing remote desktops using guacamole
https://illgrenoble.github.io/ngx-remote-desktop/
MIT License
35 stars 38 forks source link

Websocket connection failed : WebSocket is closed before the connection is established. #13

Open MeriemBo opened 5 years ago

MeriemBo commented 5 years ago

Hello , I'm using the package in my angular 6 app , and the Webstocket is closed before the connection is established. here's my code :

import { Component, OnInit } from '@angular/core'; import { RemoteDesktopManager } from '@illgrenoble/ngx-remote-desktop'; import { WebSocketTunnel } from '@illgrenoble/guacamole-common-js';

@Component({ selector: 'app-rdp', templateUrl: './rdp.component.html', styleUrls: ['./rdp.component.scss'] }) export class RDPComponent implements OnInit { private manager: RemoteDesktopManager; handleHelp() { console.log('Hello help'); } handleEnterFullScreen() { this.manager.setFullScreen(true); }

handleExitFullScreen() {
    this.manager.setFullScreen(false);
}

ngOnInit() {
    const tunnel = new WebSocketTunnel('ws://localhost:4200');
    this.manager = new RemoteDesktopManager(tunnel);
    const parameters = {
        ip: '120.18.13.142',
        port : 5000,
        type: 'rdp',
        image: 'image/png',
        width: window.screen.width,
        height: window.screen.height,
    };     
    this.manager.connect(parameters);
}

} what am I doing wrong ?

jamhall commented 5 years ago

Hi @MeriemBo !

Which websocket server are you using to proxy the connections to guacamole?

Are you using this one for testing: https://github.com/ILLGrenoble/guacamole-test-server ?

MeriemBo commented 5 years ago

No , actually I'm not using that server for testing.I didn't know that I need an intermediate server. I'll do my tests with the server you provided. but in case of production what server should I use ? thank you

jamhall commented 5 years ago

@MeriemBo - Yups, you will need an intermediate server. The intermediate server will create a websocket connection. The websocket connection will establish a connection to guacd (guacamole server) and create the RDP/VNC connection to your chosen remote server. Once a connection has been established, the RDP/VNC data will be relayed over the websocket back to the client. Alas, we have not open sourced a production server as we have a bit too much business logic for our own websocket implementation (we use a custom java socket.io server with JWT token authentication, database based role access and use an OpenStack API).

In regards to the test server: Modifying the code to use your own type of authentication/authorisation workflow shouldn't be too involved. Although it is a test server (I've tried to keep the code minimal), it should give you a good start to implement proper security policies for accessing your machines.

Good luck :-)

MeriemBo commented 5 years ago

Thank you so much for your explanation.

MeriemBo commented 5 years ago

Hello, thank you again . I am doing my tests with the test server you provided , but I don't know exactly what are the changes that should be made in the code in order to make it work for my app. Can you please clear that up ?

tavoohoh commented 5 years ago

Did you manage to solve it @MeriemBo? I'm having the same problem and I don't know anything about webSocket...

divyeshg94 commented 3 years ago

Im using the test server mentioned above., But after the test server deployment, when it hit the IP:port its throwing 404., What am I missing.