Discussion:
Remoting hangs when tcp client is missing 'channel' element
(too old to reply)
r***@gmail.com
2008-04-10 20:14:43 UTC
Permalink
Hello,
I am finding that if the remoting client is misconfigured then client
calls can hang.

I'm using .Net 2.0 and secure tcp remoting.
Server side:

<!-- Remoting hosting section -->
<system.runtime.remoting>
<customErrors mode="off"/>
<application>
<service>
<wellknown mode="SingleCall"
type="Service.ServiceImplementation, Service" objectUri="server.rem" /
</service>
<channels>
<channel ref="tcp" secure="true" port="8080" />
</channels>
</application>
</system.runtime.remoting>
</configuration>

Client side:- this setting works:

<system.runtime.remoting>
<customErrors mode="off"/>
<application>
<channels>
<channel ref="tcp" secure="true" impersonate="true"
tokenImpersonationLevel="Impersonation"/>
</channels>
</application>
</system.runtime.remoting>

If I remove the <channel> element I get no errors reported on either
end of the connection, but the client side hangs 'for ever' [got bored
after many minutes].
There is still a TCP session active, and if I exit the server then the
client fails immediately.

Does anyone know if there is a way to alter/detect/diagnose this
hang ?
In the overall system - more complex than this example - it is
sometimes very hard to diagnose this sort of configuration problem.

Regards,
Roger.
Kevin J. Stricklin
2008-05-19 16:53:00 UTC
Permalink
The problem due to the way the security negotiation works. If you don't add
the channel element to your config file, Remoting defaults to an unsecure
connection. When two Remoting processes attempt to establish a connection
where one is secure and the other isn't, they "hang". Once side is waiting
for more security information and the other side is waiting for more Remoting
data.
P***@gmail.com
2008-05-23 20:02:19 UTC
Permalink
On May 19, 11:53 am, Kevin J. Stricklin
Post by Kevin J. Stricklin
The problem due to the way the security negotiation works. If you don't add
the channel element to your config file, Remoting defaults to an unsecure
connection. When two Remoting processes attempt to establish a connection
where one is secure and the other isn't, they "hang". Once side is waiting
for more security information and the other side is waiting for more Remoting
data.
I am encountering a very similar problem. I have a secure TCP channel
here, and I have the client and the server running on the same box to
rule out any domain/trust issues. The first time I try to use the
remote object, it hangs. Does anyone have any idea how I can debug
this to find out what is wrong?

In case it matters, here is the server code (not using the config
files like earlier in this thread):

BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

Hashtable channelProperties = new Hashtable();
channelProperties.Add("port", 9765); // define the port
channelProperties.Add("secure", true);
channelProperties.Add("impersonate", true);
channelProperties.Add("name", "myname1");
ChannelServices.RegisterChannel(new TcpChannel(channelProperties,
null, provider), false);

WellKnownServiceTypeEntry entry = new
WellKnownServiceTypeEntry(typeof(MyService), "MyService.rem",
WellKnownObjectMode.SingleCall);

RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
RemotingConfiguration.RegisterWellKnownServiceType(entry);

Client code:

Hashtable channelProperties = new Hashtable();
channelProperties.Add("secure", true);
channelProperties.Add("tokenImpersonationLevel", "Impersonation");
channelProperties.Add("connectionTimeout", 5000);
channelProperties.Add("name", "myname1");
TcpClientChannel clientChannel = new
TcpClientChannel(channelProperties, null);
ChannelServices.RegisterChannel(clientChannel, false);
RemotingConfiguration.RegisterWellKnownClientType(typeof(IMyService),
"tcp://localhost:9765/MyService.rem");

IMyService myService =
(ICardCommand)Activator.GetObject(typeof(IMyService), cardCommandUri);
myService.GetData(...) // this hangs; works when everything is
instead set to not secure
P***@gmail.com
2008-05-23 20:07:56 UTC
Permalink
Sorry, at the end of the client code, it should be:

IMyService myService =
(IMyService)Activator.GetObject(typeof(IMyService), "tcp://localhost:
9765/MyService.rem");
myService.GetData(...) // this hangs; works when everything is
instead set to not secure
Post by P***@gmail.com
Hashtable channelProperties = new Hashtable();
channelProperties.Add("secure", true);
channelProperties.Add("tokenImpersonationLevel", "Impersonation");
channelProperties.Add("connectionTimeout", 5000);
channelProperties.Add("name", "myname1");
TcpClientChannel clientChannel = new
TcpClientChannel(channelProperties, null);
ChannelServices.RegisterChannel(clientChannel, false);
RemotingConfiguration.RegisterWellKnownClientType(typeof(IMyService),
"tcp://localhost:9765/MyService.rem");
IMyService myService =
(ICardCommand)Activator.GetObject(typeof(IMyService), cardCommandUri);
myService.GetData(...) // this hangs; works when everything is
instead set to not secure
Loading...