Home Forums Support Exception on reconnect

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2389
    Anonymous
    Inactive

    Hi, how can I reconnect to a remote address?
    Currently I verified the following effect for Android and Windows Phone.
    A TCP connection is established to a remote peer, then the remote peer is restarted, so that the connection is broken.
    Now a new call of TCPConnection.GetConnection leads to the following exception

    NetworkCommsDotNet.ConnectionShutdownException: Attempted to wait for connection establish on a connection that is already shutdown.
    at NetworkCommsDotNet.Connections.Connection.WaitForConnectionEstablish(Int32 waitTimeoutMS)
    
    #2393
    Anonymous
    Inactive

    Heya Ekki,

    Could you possibly provide a code sample that allows us to reproduce this problem?

    Kind regards,
    Marc

    #2427
    Anonymous
    Inactive

    Hi Marc,
    I did a lot of Investigation, but finally managed to isolate the circumstances in which the error occurs.
    It happens when a tcp and upd connection are created.

    var connectionInfo = new ConnectionInfo(new IPEndPoint(IPAddress.Parse("192.168.2.100"), Port));
    var tcpConnection = TCPConnection.GetConnection(connectionInfo, true);
    var updConnection = UDPConnection.GetConnection(connectionInfo, UDPOptions.None, true);
    

    Then also NetworkComms.AppendGlobalConnectionCloseHandler doesn’t work anymore. The ConnectionClosedHandler is never called. So NetworkComms seems not to realize that the connection is closed.

    #2428
    Anonymous
    Inactive

    Hi, I think the source of the behaviour is clear now, it’s the use of the same ConnectionInfo object for both Connections. Creating two connections with different ConnnectionInfo objects works.

    #2429
    Anonymous
    Inactive

    Heya Ekki,

    Glad you found a solution. This problem is caused due to a design choice we made in version 2.0.0 which caused a new connection to incorporate the provided ConnectionInfo parameter. This means connection specific information is added to the ConnectionInfo which obviously causes issues if two connections share the connectionInfo. I will discuss possible resolutions with our other developers.

    Kind regards,
    Marc

    #2777
    Anonymous
    Inactive

    Hi marcF

    I also encountered this problem. Even I Creating two connections with different ConnnectionInfo objects ,It’s also occur.The error message is the same.
    Attempted to wait for connection establish on a connection that is already shutdown

    my Client code like as below :

      
                private void ConnectionStateChange(connection status)
    {
                int num = 0;
                int retryCount = 1000;
                int retrySpanInMSecs = 1000;
    
               
                    do
                    {
                        try
                        {
                           
    
                            connection= TCPConnection.GetConnection(connnectionInfo);
                             
                           lblMessage.Text="ok";
                            break;
                        }
                        catch (Exception ex)
                        {
                            num++;
                            if (num < retryCount)
                            {
                                lblMessage.Text="error";
                                Thread.Sleep(retrySpanInMSecs);
                            }
                        }
                    }
                    while (num < retryCount);
    }
    

    Please give me some help

    Thanks

    Best Regards

    #2786
    Anonymous
    Inactive

    Heya msdc123,

    What version of the library are you using?

    Regards,
    Marc

    #2788
    Anonymous
    Inactive

    Heya MarcF:

    the version is 3.0.

    I think the reason may be is when the server Application close,
    The client doesn’t not clear the connection in networkcomms’s dictionary.
    and the connnection state is shutdown.

    when server restart and Client attempt to reconnect. the error will occur.

    Best Regards
    wenjie5816

    #2789
    Anonymous
    Inactive

    I’ll keep investigating.

    Regards,
    Marc

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.