Steven Cheng said:
Hi pinnguy,
Thank you for posting.
From your description, you're using .net remoting for communication between
multiple applciations, include client UI based application and service
applications. One of the client application will call a remote object from
service A, and they're using secured channel, and service A will call
another remote object from service B which does not use secured channel.
However, you found the service A can not correctly get the remote object
from service B, correct?
When the service A get error, what's the detailed error message of that
exception? Also, for such scenario, I'd suggest you try creating two
simplified application (not service) and test the same behavior. Then, we
can do further research against the simplified applications.
Regards,
Steven Cheng
Microsoft Online Community Support
Thanks Steven, you have correctly restated my configuration.
Here is the error and stack trace that occurs when service A trys to open a
TCP client connection to service B:
System.Net.Sockets.SocketException Reason=An existing connection was
forcibly closed by the remote host
StackTrace=
Server stack trace:
at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult
lazyResult)
at
System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential
credential, String targetName, ProtectionLevel requiredProtectionLevel,
TokenImpersonationLevel allowedImpersonationLevel)
at
System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateAuthenticatedStream(Stream netStream, String machinePortAndSid)
at
System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateSocketHandler(Socket socket, SocketCache socketCache, String machinePortAndSid)
at
System.Runtime.Remoting.Channels.SocketCache.CreateSocketHandler(Socket
socket, String machineAndPort)
at
System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint
ipEndPoint)
at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String
machinePortAndSid, Boolean openNew)
at
System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
at
System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage
msg, ITransportHeaders requestHeaders, Stream requestStream,
ITransportHeaders& responseHeaders, Stream& responseStream)
at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
Here is the <channels> portion of the app.config file for service A:
<channels>
<channel ref="tcp" port="10000" secure="true"
protectionLevel="EncryptAndSign" name="tcp server">
</channel>
</channels>
Here is some code snippets showing how service A attempts to create an
unsecure tcp client channel to service B:
IDictionary connInfo = new Hashtable();
connInfo["protectionLevel"] = "None";
connInfo["secure"] = "False";
connInfo["tokenImpersonationLevel"] = "None";
IChannel channel = new TcpClientChannel(connInfo,null);
try {
ChannelServices.RegisterChannel(channel,true);
}
catch (RemotingException re) {
// ignore this, it happens when channels is already registered.
}
// agntPrxyUrl - url to remoting obj in service B
ITransferAgent agent = (ITransferAgent)Activator.GetObject(
typeof(ITransferAgent),agntPrxyUrl);
// Throw SocketException here if tcp server channel is secure.
// Works just fine if tcp server channel is secure="false"
AgentStatus as = agent.Status;