Archive for April 11th, 2007
Exceptions… uggh!!!
I am presently working on a project which make use of remoting… This project was recently converted from .net framework 1.1 to 2.0. All good stories have a bad element. This one had exceptions as the bad guy.
I got three different exceptions one after the other in a loop for the same problem! I have pasted all the exception stack trace information below -
stack trace 1 :
System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
Server stack trace: at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)\r\n at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)\r\n at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateAuthenticatedStream(Stream netStream, String machinePortAndSid)\r\n at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateSocketHandler(Socket socket, SocketCache socketCache, String machinePortAndSid)\r\n at System.Runtime.Remoting.Channels.SocketCache.CreateSocketHandler(Socket socket, String machineAndPort)
stack trace 2:
System.Runtime.Remoting.RemotingException: Authentication failure —> System.IO.IOException: Unable to read data from the transport connection: The connection was closed.\r\n at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)\r\n at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)\r\n at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateAuthenticatedStream(Stream netStream, String machinePortAndSid)\r\n — End of inner exception stack trace —\r\n\r\nServer stack trace: \r\n at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateAuthenticatedStream(Stream netStream, String machinePortAndSid)\r\n at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateSocketHandler(Socket socket, SocketCache socketCache, String machinePortAndSid)\r\n at System.Runtime.Remoting.Channels.SocketCache.CreateSocketHandler(Socket socket, String machineAndPort)\r\n
stack trace 3:
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host\r\n\r\nServer stack trace: \r\n at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)\r\n at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)\r\n at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateAuthenticatedStream(Stream netStream, String machinePortAndSid)\r\n at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.CreateSocketHandler(Socket socket, SocketCache socketCache, String machinePortAndSid)\r\n at System.Runtime.Remoting.Channels.SocketCache.CreateSocketHandler(Socket socket, String machineAndPort)\r\n
After breaking my head for two days I finally found that – This error is raised in .net 2.0 framework. And that by setting “ensureSecurity” property to “false” which will allow the remoting connection to make use of the normal TCP connection rather than Negotiate Stream solves the problem… whew!!!
Then after this exception was cleared. Another exception was raised….
Stack trace:
{“A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond”}
Server stack trace: at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) 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)
After going through many many sites and many different solutions I finally landed on the correct one, which was – disable the firewall on the host system!!!
But anyways, the other solution which I thought would be helpful to others with a similar exception is – to explicitly disable default proxy support in web.config, which essentially forces a direct connection:
<system.net>
<defaultProxy>
<proxy usesystemdefault=”False”/>
</defaultProxy>
</system.net>
6 comments April 11, 2007