Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

  • Hello.
    When I run the next code I can see that the master.getValue(el), send the message to the server to close the socket.
    In the attached whireshark picture you can see it. In the whireshark picture the 192.168.2.101 is the controller (modbus tcp server) and the 192.168.2.69 is my computer.
    In this moment I have problems reading values every 500ms from one controller because every time that I read the master.getValue close the socket.

    Do you know How can we close the socket only at the end of the readings?

    Thanks.

    
     NumericLocator el = new NumericLocator(255, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);
            NumericLocator fjk = new NumericLocator(255, RegisterRange.HOLDING_REGISTER, 1, DataType.TWO_BYTE_INT_UNSIGNED);
    
            for (int i = 0; i < 1113; i++) {
                try {
                    System.out.println("el: " + master.getValue(el));
                    System.out.println("fjk: " + master.getValue(fjk));
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
    
    

    Attachment: download link


  • The problem is solved.
    When we create the master we can see a paramer keepalive in the constructor.

    ModbusMaster master = modbusFactory.createTcpMaster(ipParameters, keepalive);

    I was keepalive=false. If keepalive = false then every time that the client (master) read of the server (slave) the socket is open------close.

    If keepalive = true then the master close the socket at the end of all the readings. But I do not know how the keepalive works exactly, is it parametrizable...

    Do you know How the keepalive works exactly? And Where Can I find Modbus4j documentation?

    Best regards.