Hi guys,

First, I'd like to say I've found the modbus4j libraries an awesome tool and thank you for allowing this to be open source. Also, I'm a bit new to Java programming so I admit my comprehension of error handling is not the best. Now that being said, I have an application where I would really like to get some guidance.

The application is simple, main class creates a simple GUI with a Swing JFrame and extends two threads. First thread updates the GUI, second thread polls the modbus registers. Now everything works perfectly fine, but after the GUI runs a bit I begin getting a lot of these exceptions:

com.serotonin.messaging.WaitingRoomException: No recipient was found waiting for response for key com.serotonin.modbus4j.ip.xa.XaWaitingRoomKey@8ea
at com.serotonin.messaging.WaitingRoom.response(WaitingRoom.java:69)
at com.serotonin.messaging.MessageControl.data(MessageControl.java:153)
at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
at java.lang.Thread.run(Thread.java:745)

The ModbusMaster functions in the polling thread are the only methods that call the com.serotonin libraries, so it must be from that. The thread is very simple, when it is first called it creates the ModbusFactory, then the ModbusTCIPMaster, and then initializes the modbus locations for all the registers I'm polling. After that it enters a continuous loop with a sleep command to control the polling rate, see below:

public void run() {
System.out.println(threadName + " thread started");
this.t.setPriority(5);

    ModbusFactory m = new ModbusFactory();
    IpParameters ip = new IpParameters();
    ip.setHost(this.IPAdr);
    ip.setPort(502);
    ModbusMaster mp = m.createTcpMaster(ip, true);
    mp.setTimeout(5000);
    mp.setRetries(3);
    while (CommError) {
        try {
            mp.init();
            CommError = false;
        } catch (Exception MIExc) {
            System.out.println("Init Error: " + MIExc.getMessage());
            CommError = true;
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                //Do nothing
            }
        }
    }

    try {
        ModbusLocator ProductionSignalLoc = new ModbusLocator(1, 2, ProductionSignalAddr, 1);
        while (true) {
            Thread.sleep(NetworkUpdateRate);
            try {
                ProductionSignal = ((Boolean) mp.getValue(ProductionSignalLoc)).booleanValue();
                CommError = false;
            } catch (ModbusTransportException | ErrorResponseException MTExc) {
                System.out.println("Transport Error: " + MTExc.getMessage());
                CommError = true;
                Thread.sleep(5000);
            }
        }
    }

I cut a lot out to reduce the verbosity, but as far as I can tell ModbusMaster.getValue only throws "ModbusTransportException" and "ErrorResponseException", how am I missing the exception?

Also, any help is always appreciated :) Thanks