locked
WTSVirtualChannelOpen fails on Windows Server 2012, identical code works fine on Windows Server 2008 etc. RRS feed

  • Question

  • We try to open two Virtual Channels with the same name on a Windows Server 2012 with two WTSVirtualChannelOpen(WTS_CURRENT_SERVER, WTS_CURRENT_SESSION, "name") calls from within a single process.

    While the first call succeeds, the second call always hangs for 10 seconds and returns NULL. Afterwards called GetLastError returns 0x80004005 (unspecified error).

    This problem only happens on Server 2012, the same code works without problems on Server 2003 and 2008, using the same client.

    Firewall is disabled (personal and domain).

    •Did anything change between Server 2008 and Server 2012 that would cause such an "unspecified error"?
    •Is there any way to get more detailed information on the cause of the error (e.g. activate logging on WTS... functionality)?
    Any answers are appreciated ...

    Andreas

    PS: There seem to be several related issues reported e.g. in unanswered threads http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/b0705799-4a22-43e8-b5e5-d0b1f60e1cad and http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/0823f44f-785b-4c5c-b809-61a4a74327e2

    • Edited by Andreas Neubacher Wednesday, November 28, 2012 12:42 PM Updated description; added links to related threads
    Tuesday, November 27, 2012 4:45 PM

All replies

  • Hi Andreas,

    Do you see this issue if you use WTSVirtualChannelOpenEx?

    -TP

    Tuesday, November 27, 2012 8:50 PM
  • We've experimented a bit more, also trying WTSVirtualChannelOpenEx, the behavior is unchanged.

    Please note that I've also updated the description - the issues occurs on the second call with the same channel name.

    Wednesday, November 28, 2012 12:42 PM
  • Hi,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
    Thank you for your understanding and support.

    Regards,

    Clarence

    TechNet Subscriber Support

    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedbackhere.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, November 30, 2012 5:12 AM
  • Same issue in Windows Server 2012 and Windows 8. I have also used the WTSVirtualChannelOpenEx, but with the same behavior.

    Tuesday, December 4, 2012 3:38 PM
  • check if the following MSDN can helps on this issue:

    http://msdn.microsoft.com/en-us/library/windows/desktop/Hh769144(v=vs.85).aspx

    You can submit another thread in MSDN forum:

    http://social.msdn.microsoft.com/forums/en-US/categories/


    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.”

    Wednesday, December 5, 2012 2:06 PM
  • Kevin,

    The link you give points to the "WTSGetChildSessionId" function.  Could you please explain how this should relate to the error we are observing in WTSVirtualChannelOpen/Ex?  The documentation of "Child Sessions" says that

    A child session can only be created from within an existing user's session by using the Remote Desktop ActiveX control and setting the "ConnectToChildSession" property with IMsRdpExtendedSettings.Property prior to connecting

    This does not relate to any scenario relevant to our use case - and also does not explain why everything works fine on Server2008 with identical clients.

    Andreas

    Wednesday, December 5, 2012 4:43 PM
  • Suffering from the same issue. Any updates on this?
    Wednesday, January 16, 2013 4:58 PM
  • Nope, all's quiet from the MS side.  We are currently investigating workarounds and in the meantime telling customers that they must not use Server 2012 with our product.

    You might try to start a separate thread on this topic - perhaps you have more luck with feedback than I had ...

    Andreas


    Wednesday, January 16, 2013 5:17 PM
  • Hi Andreas,

    I discussed with the MSDN engineer, i have the following information:

    You issue:

    1. You are not supposed to open the same channel twice in Windows Server 2012.
    2. Also, you are not supposed to open the same channel from two different processes Windows Server 2012.

    Resolution

    "Up until the Win 2012 release the stack was running in kernel mode and SVC were implemented differently. Opening the same SVC twice wasn’t supported, but wasn’t prevented either. From what I remember about the kernel implementation the scenario described in #1 and #2 would work some of the time, but only when there are enough pending reads on the channel. As soon as the reads dry it is unpredictable which handle will get the data. These examples probably never run into this problem because either the incoming traffic was small and sparse or because they had enough pending reads to be able to handle the incoming data.
    #1 can be worked around with a small change, instead of opening the channel twice they could DuplicateHandle() of the channel and use the second channel handle as they did before.
    For #2, DuplicateHandle() would be possible solution if they have a way to communicate between the apps"

    Does the workaround work on your issue?


    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.”

    Tuesday, January 29, 2013 2:04 AM
  • Hi Kevin,

    Thank you for the useful infomation. Could you get more detail for us please:

    1- Is it a system-wide rule or only to a specific session (session wide) ?

    2- How about calling Open then Close and Open again ?

    3- Where can we get more detail on the new implementation of Virtual Channel on Windows 2012 to make fix of our programs ?

    Thank you very much & Best regards

    Thomas Tran

    Tuesday, January 29, 2013 6:09 PM
  • Hi Kevin,

    The documentation for DuplicateHandle does not list WTS channel handles and such handles are not closed using CloseHandle but rather using WTSVirtualChannelClose.  Therefore I wonder if that workaround is really an officially supported solution.

    We never had problems up to now because our applications that have all opened the channel make sure that there's always only one active reader/writer.  All others have the channel open but do not access it until it is their turn.

    We are now testing a change where the applications will always close/reopen the channel when they lose/gain access and hope that performance will still be acceptable.

    Andreas

    Thursday, February 21, 2013 3:31 PM
  • Hi Thomas and Andreas,

    Please focus on the my reaply for if any useful information on your issue, that is all we can provide in this Remote Desktop forum, however if you have individuel issue needs our MSDN, or DEV team in further troubleshooting, I’d like to suggest that you submit a service request to MS Professional tech support service so that a dedicated Support Professional can further assist with this request.

    Please visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone


    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.”

    Sunday, February 24, 2013 12:56 PM
  • Hello everyone,

    Is there someone who has successful to make the Virtual Channel works correctly under Windows 2012/R2?

    I have created a COM object that contains all Virtual Channel functions like WTSVirtualChannelOpen, WTSVirtualChannelRead and WTSVirtualChannelWrite to make sure that the WTSVirtualChannelOpen is called just once. However, sometimes I still get error. Especially with WTSVirtualChannelRead, it has a lot of error "Invalid Access Memory Location" (998).

    Here is my observation about Virtual Channel problem on Windows 2012:

    - WTSVirtualChannelOpen: can be failed at the first call in the session.

    - WTSVirtualChannelWrite: has a strange behavior, in this document it shows that by adding a Sleep 1 sec, it may help:
    https://connect.microsoft.com/VisualStudio/feedback/details/737034/wtsvirtualchannelclose-aborts-completed-dynamic-virtual-channel-io

    - WTSVirtualChannelRead: "Invalid Access Memory Location" (998).

    I really don't know why Virtual Channel becomes so buggy in Windows 2012/R2 . I have worked with Virtual Channel since Citrix Metaframe XP v1.0, Windows 2000, 2003 and Windows 2008/R2, all functions works as expected till Windows 2012. Either I have followed the workaround suggested here, it does not work very well, errors can happen very unpredictable.

    For the error "Invalid Access Memory Location" (998), I think may be my COM component (EXE) is a 32-bit (I have tried both with VB6 and VC++ ATL). I have found an article about a bug of a memory conversion function, but does it still exists in Windows 2012?

    I have made a work around for this problem by putting all Virtual Channel functions inside an EXE COM, when an error occurs I have to shutdown the COM process and reload it again, usually it works, sometimes it needs several tries. It can work but this solution is not clean.

    Is there someone who find a better solution for these bugs, while waiting for the MSDN team figures out and recognizes these bugs and can provide us a fix on that? I'm really in despair.

    Regards

    Thomas Tran

    Tuesday, November 11, 2014 10:38 PM
  • Hi,

    On Server 2012 (non R2), does the hotfix below help at all?

    RDP virtual static channels don't work and an operation stalls in Windows Server 2012

    http://support.microsoft.com/kb/2802311

    Have you opened a paid support case with Microsoft CSS yet?

    -TP

    Wednesday, November 12, 2014 2:58 AM
  • No, I didn't.

    I'm trying with Windows 2012R2, I don't get the bug of 10 sec delay. However, I constantly get failed with WTSOpenVirtualChannel function with Unspecified Error, the solution is clean up everything and reload WTSAPI32.DLL module and retry, it will work randomly.

    I have to use my workaround solution for clients who are already using Windows 2012, for other clients I have to tell them not to use/upgrade to Windows 2012/R2 for now.

    Regards

    Thomas Tran


    Wednesday, November 12, 2014 6:22 PM
  • Has a solution been found for this issue?
    Saturday, March 12, 2016 5:25 PM
  • Sadly there is no news from MS team about these bugs.

    All I can find is from a Delphi forum to deal with WTSOpenVirtualChannel is to try it several time if it fails. It seems working for me. C++ code works more stable than with other languages. When transferring between the sides, try to reduce the buffer size will help. Don't use the maximum 1600 allowed as specified in the document, sometimes some bytes get overridden, very annoying since Windows 2012.

    Some body claim that Dynamic Virtual Channel works better, but I'm not sure if it's true or not. In fact DVC still use a static VC and it does the multiplex in that same channel. I didn't do enough tests to see if DVC works better or not . Some companies mention that their products use DVC to provide multiple connections but that's not true. My customer reported this problem to me and we did the test and can confirm that static virtual channel still work, but under Windows 2012/R2 it's buggy . Still waiting for MS giving the fix for those bugs

    Thomas Tran

    Monday, March 14, 2016 5:27 PM
  • Has there been any movement on this? it seems to also be happening in server 16
    Friday, August 18, 2017 2:02 PM