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

Unhandled Exception during errors in clientconnection.js #23

Open duhiga opened 5 years ago

duhiga commented 5 years ago

First off, awesome library. Love it.

I'm getting unhanded exceptions and crashing when (I think) users with high latency disconnect (I think). From what I can tell this occurs if the websocket is already disconnected before clientconnection.error fires a server.emit. Handling this would look something like:

ClientConnection.js:

...
error(error) {
        try {
            this.server.emit('error', this, error);
        } catch (err) {
            this.log(this.server.LOGLEVEL.ERRORS, 'Failed to send error to client: ', error);
        }
        this.close(error);
    }
...

I have not been able to reproduce this myself, but am working off stack traces and believe this to be the issue. Can you take a look at this and perhaps add in some catching/validating at this stage?

mrvisser commented 3 years ago

I've experienced this fairly regularly on a high-traffic VNC connection.

I've bound a listener to server.on('error', ...) as well but it doesn't help.

mrvisser commented 3 years ago

The exception raised to process was actually a chain reaction from another stream I had open. So long as you listen on server.on('error'...) in your own code, should be all good.