Exceptions… uggh!!!

April 11, 2007 at 3:39 am 9 comments

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>

For more information try out this link and this one.

Advertisements

Entry filed under: .net, exceptions, proxy, remoting, Visual Studio, WebApplication.

Defy all challenges

9 Comments Add your own

  • 1. Noella  |  August 27, 2007 at 12:37 pm

    Thank you for this , Luckily I just had to break my head for three hours and I found this.

  • 2. Sudheer  |  September 27, 2007 at 2:00 am

    Thank you so much..
    You saved a lot of time and from severe frustration…!!

  • 3. Maysam Ghanbari  |  November 10, 2007 at 5:46 pm

    Thank you very very much,
    At last, your guide have solved my problem.
    Sincerely

  • 4. Boštjan  |  April 4, 2008 at 11:02 am

    Most helpfull! 🙂
    Thank you very much!

  • 5. António Inácio  |  April 22, 2008 at 11:57 am

    Thank you!
    Very helpfull!

  • 6. Carlos navarro  |  November 24, 2008 at 6:08 am

    I’ve enabled port 43 and added the script to my .config file. Still the same error.

  • 7. bd  |  February 18, 2010 at 5:21 am

          

  • 8. mrahim  |  December 14, 2011 at 12:05 pm

    Thanks very much. Your article solved my problem.

  • 9. nka  |  December 27, 2011 at 8:33 am

    since 2007 now in 2011 it’s still helps, a lot of thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


April 2007
M T W T F S S
    May »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

%d bloggers like this: