Home Bug Reports

Ice C# version 1.5 connect exception

wodiwodi Member
Hi,

the following is a stack trace from Ice C# demo Hello in version 1.5.
The tests also throw this exception on the first checkedCast.
Any hints are welcome.
This is on Windows XP SP1 with the .NET runtime. The Alpha 2 version did not have any problems on this platform.

Client output:
Ice.ConnectFailedException: Connect failed ---> System.Net.Sockets.SocketException: Eine Verbindungsanforderung bezog sich auf einen bereits verbundenen Socket
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at IceInternal.Network.doConnect(Socket socket, EndPoint addr, Int32 timeout) in D:\Projects\icecs\Network.cs:line 366
--- End of inner exception stack trace ---
at IceInternal.ProxyFactory.checkRetryAfterException(LocalException ex, Int32 cnt) in D:\Projects\icecs\ProxyFactory.cs:line 104
at Ice.ObjectPrxHelperBase.__handleException(LocalException ex, Int32 cnt) in D:\Projects\icecs\Proxy.cs:line 585
at Ice.ObjectPrxHelperBase.ice_isA(String __id, Context __context) in D:\Projects\icecs\Proxy.cs:line 104
at Ice.ObjectPrxHelperBase.ice_isA(String __id) in D:\Projects\icecs\Proxy.cs:line 84
at HelloPrxHelper.checkedCast(ObjectPrx b) in d:\projects\helloclient\helloclient\hello.cs:line 289
at Client.run(String[] args, Communicator communicator) in D:\Projects\HelloClient\Client.cs:line 43
at Client.Main(String[] args) in D:\Projects\HelloClient\Client.cs:line 156

Server Output:
HelloServer.exe: warning: connection exception:
Ice.ConnectionLostException: ConnectionLostException ---> System.Net.Sockets.SocketException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at IceInternal.TcpTransceiver.read(BasicStream stream, Int32 timeout) in D:\Projects\icecs\TcpTransceiver.cs:line 185
--- End of inner exception stack trace ---
at IceInternal.TcpTransceiver.read(BasicStream stream, Int32 timeout) in D:\Projects\icecs\TcpTransceiver.cs:line 217
at IceInternal.Connection.read(BasicStream stream) in D:\Projects\icecs\Connection.cs:line 985
at IceInternal.ThreadPool.read(EventHandler handler) in D:\Projects\icecs\ThreadPool.cs:line 676
at IceInternal.ThreadPool.run(BasicStream stream) in D:\Projects\icecs\ThreadPool.cs:line 541
local address = 192.168.1.101:12345
remote address = 192.168.1.101:1158
HelloServer.exe: warning: connection exception:
Ice.ConnectionLostException: ConnectionLostException ---> System.Net.Sockets.SocketException: Eine vorhandene Verbindung wurde vom Remotehost geschlossen
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at IceInternal.TcpTransceiver.read(BasicStream stream, Int32 timeout) in D:\Projects\icecs\TcpTransceiver.cs:line 185
--- End of inner exception stack trace ---
at IceInternal.TcpTransceiver.read(BasicStream stream, Int32 timeout) in D:\Projects\icecs\TcpTransceiver.cs:line 217
at IceInternal.Connection.read(BasicStream stream) in D:\Projects\icecs\Connection.cs:line 985
at IceInternal.ThreadPool.read(EventHandler handler) in D:\Projects\icecs\ThreadPool.cs:line 676
at IceInternal.ThreadPool.run(BasicStream stream) in D:\Projects\icecs\ThreadPool.cs:line 541
local address = 192.168.1.101:12345
remote address = 192.168.1.101:1157

Cheers,

Wodi

Comments

  • wodiwodi Member
    Hi again,

    ok, I found a solution:

    disable in Network.cs the Mono fix

    if(ready && !socket.Connected)
    {
    goto repeatConnect;
    }

    around line 404.

    It will work then on Windows with .NET. Any explanation please!

    Cheers,

    Wodi

    PS:

    all tests complete successful on .NET after fixing Network.cs:

    #if __MonoCS__
    if(ready && !socket.Connected)
    {
    goto repeatConnect;
    }
    #endif
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    Originally posted by wodi
    disable in Network.cs the Mono fix

    if(ready && !socket.Connected)
    {
    goto repeatConnect;
    }

    around line 404.

    It will work then on Windows with .NET. Any explanation please!

    Hi Wodi,

    the problem is that, with Mono under Linux, there is a problem in the Connect() behavior: a select after a non-blocking connect returns a writable file descriptor (indicating that the connection is established) when, in fact, the connection is not established. Interestingly, restarting the call to select doesn't fix this (that is, the socket remains unconnected thereafter), but restarting the connect call does.

    I tried this hack with .NET under Windows as well, and had no problems, which is why I left it enabled for both .NET and Mono.

    #if __MonoCS__		    
                if(ready && !socket.Connected)
               {
               goto repeatConnect;
               }
    #endif
    

    Ah, that isn't quite the correct fix. The problem with __MonoCS__ is that this is a compile-time test. So, if you compile something with mcs and then copy the binaries to a Windows machine with a .NET run time, it will still fail. One correct (simple) fix for now is to change the test to read:
    if(ready && System.Type.GetType("Mono.Runtime") != null && !socket.Connected)
    

    Thanks for the bug report, Wodi. This will be fixed for the next release, of course.

    Cheers,

    Michi.
Sign In or Register to comment.