Initially, I am connected to a server using RDP, when I am trying to connect to the same server using VNC viewer, the RDP connection drops. I have installed tigervnc on the remote server. I tried the same thing using TightVNC, the RDP connection is still active. Kindly let me know why the RDP connection is getting disconnected and how TightVNC is able to keep the RDP session alive. If possible kindly provide the code snippet or at least provide me the direction that would help me further, Kindly let me know, also I have never worked on these kinds of projects before so I don't have enough knowledge. Any kind of help would be of great help.
I'm trying to track down the code responsible in the TigerVNC code base but my suspicion is that (which is basically confirmed by multiple other superuser and other blog posts) is that when launched as a service, as opposed to a process after login, the vnc server utilizes termsrv.dll
So when you connect the second session (RDP in this case) unless you are on a licensed Terminal Server, you aren't allowed a second RDP session, so the first one is terminated.
You might be able to work around this by launching the VNC server after connecting via RDP and not running it as a Windows service, but you won't be able to interact with UAC via VNC in this case.
Alternatively RDP Wrapper might help. Or there are other ways involving patching termsrv.dll but I'm not going to document those as they are not exactly above board.