I originally posted about this at http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/Need-guidance-with-suspected-auto-reconnect-bug-td2118.html and then replied later to another thread at http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/Error-message-when-disconnecting-a-Windows-Server-2012-td1835.html#a2129 stating that Frode Langelo's patch fixed my issue as well. Opening bug report per Nick Couchman's request and copy/pasting from these referenced threads below.
I have a single connection to an RDP server. The server is set up to only allow one connection per user, so when I leave one guacamole session connected, and start up another one (e.g., open A in chrome and B in an incognito window), the session detaches from A and attaches to B.
This (erroneously) triggers the 15 second auto-reconnect countdown in A. Once it reconnects, B is disconnected and starts the 15 second countdown. It ping-pongs back and forth.
Running "guacd -L debug -f" I see this:
Lines 1 and 2 actually come from libfreerdp, and indicate that the error code coming from RDP is 0x5. Looking at guacd: src/protocols/rdp/error.c
So a 0x5 return from RDP should translate to GUAC_PROTOCOL_STATUS_SESSION_CONFLICT (0x209) being sent to the client.
Looking at the client, in guacamole/target/guacamole-0.9.13-incubating/guacamole.js:
0x0209 isn't in the list that should auto-reconnect. So I added this in guacamole.js:
In the session B console in Chrome, when the reconnect in session A, for example, disconnects session B, I see this:
That's not 209, but it IS in the auto-reconnect list.
So I started tracking down why libfreerdp sends 0x5 to guacd, which should send 0x209 to the client, but instead is sending 0x208. Here's what I found (the clue was line 3 above in the guacd debug output:
In function guac_rdp_handle_connection:
and lower down:
The first bit is returning GUAC_PROTOCOL_STATUS_UPSTREAM_UNAVAILABLE, which is 0x208, to the client and returning. This means guac_rdp_client_abort, which maps the RDP error codes to GUAC_PROTOCOL_STATUS*, is never reached. I poked it a bit and realized I was in over my head. I'd need to understand more about freerdp_check_fds and freerdp_shall_disconnect before I could decide how to rework it.
I am not sure what all error conditions from RDP will trigger the first bit and return before guac_rdp_client_abort is called, but I am guessing that more than 0x5 is getting short circuited and arriving at the client as a 0x208.
Excerpt from mailing list with Frode's patch:
I am seeing the same behavior as Kevin; Windows 2008 does not give this error, while both 2012 and 2016 do. I found the easiest way to reproduce this is to connect to the box but not do anything in the Windows logon screen. The RDP server will disconnect the session and the referenced error is produced. The freerdp version I am using is 1.1.0~git20140921.
Kevin; try adding this to src/protocols/rdp/rdp.c for remedy: