Ylianst / MeshCentral

A complete web-based remote monitoring and management web site. Once setup you can install agents and perform remote desktop session to devices on the local network or over the Internet.
https://meshcentral.com
Apache License 2.0
3.94k stars 531 forks source link

RDP connection fails when using MeshCentral Router #2811

Closed mgauthierUnicel closed 3 years ago

mgauthierUnicel commented 3 years ago

Hi,

I'm not sure if I should post in the server issues or MeshRouter's.

I'm trying to get through a weird issue with MeshCentral2 (either v0.7.89 or v0.8.65) where a rdp connection tunneled through MeshCentral router drops systematically (the connection seems to work for a few frames to be transferred after login and fails with the following error message). 2021-06-23 11_55_09-Remote Desktop Connection

Server is running Windows 2012r2, both remote and local machines are Windows 10 Pro running 20h2 and all are domain joined.

I can easily RDP in the remote machine from the local one without using MeshCentral and the connection is rock solid.

Here is the configuration of the server

{
   "settings": {
      "lanonly": true, 
      "_minify": true, 
      "selfupdate": true, 
      "_clickonce": true, 
      "webrtc": true,
      "compression": true,
      "wscompression": false,
      "agentwscompression": true,
      "desktopMultiplex": true
   }, 
   "domains": {
        "": {
            "title": "MeshCentral 2",
            "auth": "sspi",
            "newAccounts": false,
            "_httpHeaders": {
            "Strict-Transport-Security": "max-age=360000",
            "x-frame-options": "SAMEORIGIN"
            }
        }
    }
}

any idea of what could cause the connection to drop when going through MeshCentral ?

Ylianst commented 3 years ago

Reformated your ocnfig.json using JSON lint from DuckDuckgo.

Note that "clickonce" is not longer supported and that setting is ignored. I don't really recommend "selfupdate" to true since it's best to be around when the update occurs... but for small servers it may be ok.

{
  "settings": {
    "lanonly": true,
    "_minify": true,
    "selfupdate": true,
    "_clickonce": true,
    "webrtc": true,
    "compression": true,
    "wscompression": false,
    "agentwscompression": true,
    "desktopMultiplex": true
  },
  "domains": {
    "": {
      "title": "MeshCentral 2",
      "auth": "sspi",
      "newAccounts": false,
      "_httpHeaders": {
        "Strict-Transport-Security": "max-age=360000",
        "x-frame-options": "SAMEORIGIN"
      }
    }
  }
}

Testing RDP now...

Ylianst commented 3 years ago

Ok, my RDP works fine for me. It looks like your getting data corruption and I am going to take a guess that your running an old version of MeshCentral Router that does not deal well with web socket compression or something else. Re-download and run MeshCentral Router from your server and try again.

LPJon commented 3 years ago

@Ylianst I'm having this same problem with the same OS. Nothing about my network or the remote network has changed. My MeshRouter Version is 1.1.7846. How do I download this directly from my MeshCentral Server Again? Also here are some console logs from the remote agent. Maybe it will help.

TUNNEL: {"action":"msg","type":"tunnel","userid":"<PRIVATE>","value":"*/meshrelay.ashx?id=<PRIVATE>","tcpport":"3389","tcpaddr":"127.0.0.1","soptions":{"consentTitle":"Laptop Pitstop® Hyper Connect™","consentMsgDesktop":"{0} is requesting remote desktop access. Grant access?","consentMsgTerminal":"{0} is requesting remote terminal access. Grant access?","consentMsgFiles":"{0} is requesting remote files access. Grant access?","notifyTitle":"Laptop Pitstop® Hyper Connect™","notifyMsgDesktop":"{0} started a remote desktop session.","notifyMsgTerminal":"{0} started a remote terminal session.","notifyMsgFiles":"{0} started a remote files session."},"rights":<PRIVATE>,"consent":0,"username":"<PRIVATE>","realname":"<PRIVATE>","privacybartext":"Connected with a Laptop Pitstop® Hyper Connect™ Technician"}
uncaughtException1: Error:  => EventEmitter.emit(): Event dispatch for 'end' on 'http.WebSocketStream.decoded' threw an exception: ReferenceError: identifier 's' undefined in method 'onTunnelClosed()'
LPJon commented 3 years ago

@Ylianst I can confirm this seems to be MeshRouter related. Versions 1.7.7837 and 1.7.7846 both show this problem. At the moment of RDP login when the screen is switching the RDP connection is lost.

MeshRouter Version 1.7.7827.22119 found here works perfectly as expected with no issues at all and is the latest version that does not have this issue.

This version, committed on June 9th, is where this problem begins to surface. It might be related to delays were network packets are traveling over NAT's. Whatever the case Meshagent is closing the connection for some reason, probably related to the exception I listed in the last comment.

@mgauthierUnicel Try the version of MeshRouter I linked above and see if your problem still exists.

Ylianst commented 3 years ago

Oh dear!!! Thank you for reporting this in such detail. Will take a look at this ASAP.

LPJon commented 3 years ago

No problem...I should also mention that this is effecting more than RDP. SSH, SCP, http, https.....they all seem to be suffering. Some will still work but be slow or studder unless you back up to the MeshRouter version I mentioned.

Ylianst commented 3 years ago

You can get the latest MeshCentral Router here, v1.8.7853. I just made a bunch of fixes to it and if you can try it and give me a report back, that would be great.

For my testing, I would RDP and send a 1 gigabyte file thru and it would indeed disconnect. I fixed flow control and a cross-thread issue and it seems to work great now. Yes, that would affect all tunnels. Let me know if it fixes it for you.

maccn commented 3 years ago

Thanks @Ylianst for the prompt fix. I used to got the same error, and tried your fixed version(v1.8.7853) which works great now.

LPJon commented 3 years ago

@Ylianst I can confirm that Version 1.8.7853 is now working with RDP, SSH, SCP, HTTPS, HTTP without studders delays or disconnects. Thanks for the fast response on this as I use MeshCentral Router A LOT!

Ylianst commented 3 years ago

Nice. thanks for reporting back. These MeshCentral Router improvements should have been done a long time ago, it's flawless now in my testing.