rossmann-engineering / EasyModbusTCP.NET

Modbus TCP, Modbus UDP and Modbus RTU client/server library for .NET implementations
922 stars 396 forks source link

[BUG]ModbusClinet.ReadHoldingRegisters Throw NullReferenceException(在我的程序具有重连功能时引发的异常) #75

Open jkh404 opened 2 years ago

jkh404 commented 2 years ago

QQ图片20220125133440 上面的图片是Visual Studio2019 Debug 调试运行时抛出的异常。出现的位置是EasyModbusTCP.NET项目的ModbusClient.cs的ReadHoldingRegisters 方法 注意:这个 BUG是偶尔发生的,按照以下说明操作可以大概率重现。 情景重现: 我的程序是具有掉线重连功能的,每隔一秒会检查是否断开连接,如果断开连接则调用 Connect() 重新连接。 image 当我启动我的程序,然后再立刻启动ModBus Tcp Server 监听端口,最后抛出了异常。

en: Visual Studio2019 Debug debuts an exception thrown at runtime. The location where this occurs is the ReadHoldingRegisters method of the modBusClient. cs of the EasyModbusTCP.NET project Note:This bug happens occasionally.Follow the instructions below to have a high probability of recurrence Re-enactment: My program is a disconnected reconnect function, every second will check whether to disconnect, if disconnected call Connect() to reconnect. When I started my program and then immediately started ModBus Tcp Server listening port, finally threw an exception.

jkh404 commented 2 years ago

我用的版本是5.6 en: I'm using version 5.6