Groups | Blog | Home
all groups > dotnet remoting > february 2008 >

dotnet remoting : Remoting on Terminal Server


tosch
2/21/2008 4:31:39 AM
I have to apps that communicate using remoting. This works fine on a
single machine.
When I run the same on a terminal server I get an error when
registering a channel, when the second client starts the application.
Why do I get this error? How can I resolve this Issue

Nicolas Bouchard
2/21/2008 6:05:39 AM
[quoted text, click to view]

The problem you have is due to the fact that you cannot open more than
1 port on the same computer.

I had the same situation lately. The solution I used is quite
simple. I get the session id from the terminal server and add it to
my port. That assure me I got a unique port for every session. To get
the remoting session id use the following method:

[System.Runtime.InteropServices.DllImport("kernel32.dll")]
static extern bool ProcessIdToSessionId(uint dwProcessId, out
uint pSessionId);

public long GetRemotingPort()
{
uint sessionId =3D 0;
System.Diagnostics.Process currentProcess =3D
System.Diagnostics.Process.GetCurrentProcess();
bool result =3D ProcessIdToSessionId((uint)currentProcess.Id,
out sessionId);
return 65000 + sessionId;
}


In this example, I removed all error trapping validation. The base
port i was using is 65000 and if not on a terminal server, the
ProcessIdToSessionId returns 0.

tosch
2/21/2008 6:47:08 AM
On 21 Feb., 15:05, Nicolas Bouchard <nicolas.bouch...@gmail.com>
[quoted text, click to view]

Nicolas,
thanks for your good solution. Can the port number ever be to big?
What's the max for the session id?

Nicolas Bouchard
2/21/2008 7:12:45 AM

[quoted text, click to view]

The number maximum of session on terminal server depends on the
licensing used. The minimum is 5 licenses. The highest TCP port
AddThis Social Bookmark Button