The sendRDPFile function does not have a connect method passed to it. So, it has to get information about all connect methods and try to match any related to RDP. Depending on the order it gets from the database, if there are more than one connect methods with "remote desktop" or RDP in the description, the wrong one may be selected. If that one uses a different port that what the user needs, the wrong port will be specified in the .rdp file.
The best fix for this is to pass the connect method id in the continuation used for getting the RDP file. Then, connect method information for only that connect method can be used.