MangoAutomation / modbus4j

A high-performance and ease-of-use implementation of the Modbus protocol written in Java. Supports ASCII, RTU, TCP, and UDP transports as slave or master, automatic request partitioning and response data type parsing.
GNU General Public License v3.0
897 stars 370 forks source link

StreamTransport::removeConsumer方法bug #70

Open l505654754 opened 6 months ago

l505654754 commented 6 months ago

使用RtuMaster发送消息只要发生异常就会关闭连接调用到这个方法,而下次尝试打开连接又会先调用这个方法产生空指针从而打开失败。导致永远都连不上,除非自己创建新的RtuMaster实例

package com.serotonin.modbus4j.sero.messaging;
public class StreamTransport implements Transport, Runnable {

...

    /**
     * <p>removeConsumer.</p>
     */
    public void removeConsumer() {
        listener.stop();
        listener = null;
    }

...
}