kubekWkubek

Omron FINS/TCP Reconnecting

2 posts in this topic

Hey

I'm trying to implement reconnecting for FINS/TCP protocol, according to W421 Omron documentation (link: https://assets.omron.eu/downloads/manual/en/v4/w421_cj1w-etn21_cs1w-etn21_ethernet_units_-_construction_of_applications_operation_manual_en.pdf ), but it not working.

According to diagram in 7-4 section at 183 page, after connection lost and restore connection to the Internet, Client(PC) should again connect with PLC using the same Client(PC) FINS Node Id. PLC should detect connection error and response with error code 00000021 hexadecimal: Specified node is already connected. It works. After this should I close socket (created after restore connection) or this socket should be closed automatically by PLC? Then I should create new socket (third) and connect with the same Client(PC) FINS Node Id should be possible. But i've got "Specified node is already connected" error again. PLC dosn't forget before connection. Why? What I'am doing wrong?
 

// Client FINS Node id = 50, Server FINS Node id = 10. Standard communication works

	public void TestReconnect()
        {
            // connect on TCP Layer
            this.tcpClient.Connect(base.ipEndpoint); 
            // NADS Frame - finsClientNode = 0 - autoallocation
            this.SendNodeAddressDataSend();

            // Power interruption!!!

            // creating new socket, old socket is unavailable
            this.tcpClient = new TcpClient(); 
            // connect on TCP Layer
            this.tcpClient.Connect(base.ipEndpoint);
            // NADS Frame - use finsClientNode autoallocated before
            // should return error "The specified node is already connected."
            this.SendNodeAddressDataSend(); 
            // disconnect on TCP Layer, should i do this?
            this.tcpClient.Close();

            // creating new socket, old socket was closed
            this.tcpClient = new TcpClient();
            // connect on TCP Layer
            this.tcpClient.Connect(base.ipEndpoint);
            // NADS Frame - use finsClientNode autoallocated before
            // shouldn't return error "The specified node is already connected."
            // because connection with this node was closed before
            this.SendNodeAddressDataSend(); 
        }

        private NodeAddressDataSendResponse SendNodeAddressDataSend()
        {   /*
            byte clientNodeId = finsRequestDataProvider.GetClientNodeId();
            byte[] header = new byte[]
            {
                    F, I, N, S, // 'F' 'I' 'N' 'S'
        			0x00, 0x00, 0x00, 0x0C,	// 12 Bytes expected
        			0x00, 0x00, 0x00, 0x00,	// NADS Command (0 Client to server, 1 server to client)
        			0x00, 0x00, 0x00, 0x00,	// Error code (Not used)
        			0x00, 0x00, 0x00, clientNodeId  // Client node address, 0 = auto assigned
            };*/
            var nodeAddressDataSendRequest = this.finsRequestFactory.CreateNodeAddressDataSendRequest();
            var nodeAddressDataSendResponse = this.Execute(nodeAddressDataSendRequest);
            this.finsRequestDataProvider.StoreAutoallocatedNodeId(nodeAddressDataSendResponse.ClientNodeId, nodeAddressDataSendResponse.ServerNodeId);
            return nodeAddressDataSendResponse;
        }

 

Thanks for any help

 

 

 

 

 

Share this post


Link to post
Share on other sites

PMCR / Michael Walsh be the best to reply here, but sounds like the PLC is keeping the socket open perhaps or the disconnect/close command in your api is not succeeding

what PLC are you trying to connect/test with.? The smaller bricks only have 3x sockets available ..

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now