Question

I have successfully created a desktop sharing solution where an RDPViewer connects to an RDPSession. That's all working beautifully. Now, however, I'm trying to get the opposite to work: using the RDPViewer's StartReverseConnectListener method, and RDPSession's ConnectToClient method (where the session side would connect to the viewer side to work around NAT/Firewall issues). I've followed the steps outlined at http://msdn.microsoft.com/en-us/library/windows/desktop/aa373359%28v=vs.85%29.aspx, mainly:

  1. The viewer obtains its connection string by calling the StartReverseConnectListener method, passing NULL for the bstrConnectionString, bstrUserName, and bstrPassword parameters.

  2. The viewer initiates a reverse connect listener by calling the StartReverseConnectListener method, passing NULL for the pbstrReverseConnectString parameter and valid values for the bstrConnectionString, bstrUserName, and bstrPassword parameters.

  3. The viewer sends the connection string obtained in step 1 to the sharer.

Using C# 2010, I've done the following on the RDPSession side:

RDPSession session = new RDPSession();
session.Open();
session.Invitations.CreateInvitation(null, "test", "12345", 1);

Then, on the RDPViewer side, I've done:

string reverseConnectString = axRDPViewer1.StartReverseConnectListener(null, null, null);

(step 1, above)

axRDPViewer1.StartReverseConnectListener(reverseConnectString, "test", "12345");

(step 2, above)

Then, back on the RDPSession side, I attempt to make the connection using the reverseConnectString I obtained from the viewer (I actually saved the string to a file, and then loaded it on the RDPSession side):

session.ConnectToClient(reverseConnectString);

(step 3, above)

As soon as I execute this method, the RDPViewer side disconnects with an error of 1798, which, according to http://msdn.microsoft.com/en-us/library/aa373802%28VS.85%29.aspx, means:

ServerCertificateUnpackErr 1798

Failed to unpack server certificate.

I feel like I'm missing something obvious, but I can't figure out what.

Any suggestions?

Thanks!

Was it helpful?

Solution

The Microsoft documentation is all wrong regarding reverse connections. Here's what you need to do (adapted from your code above):

RDP Session Side:

RDPSession session = new RDPSession(); 
session.Open(); 
string hostConnString = session.Invitations.CreateInvitation(null, "My Group Name", "12345", 1);

RDPViewer side (note that hostConnString should be the same value as retrieved on the session side):

string viewerConnString = axRDPViewer1.StartReverseConnectListener(hostConnString, "My Name", "12345");

Now back to the RDP session side (note that the viewerConnString should be the same value as retrieved from the viewer side):

session.ConnectToClient(viewerConnString); 

And that should do it. A couple of things to note. The group name specified in CreateInvitation does not need to match anything anywhere else. I think it's just for reference should your program need to enumerate the invitations started by the host. The user name passed to StartReverseConnectListener can also be anything you want. This can be interrogated and used on the host side by looking at the RemoteName property in the IRDPSRAPIAttendee interface.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top