ILLGrenoble/ngx-remote-desktop

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

Opened this issue · 7 comments

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 ?

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 ?

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

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

Thank you so much for your explanation.

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 ?

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

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.