mysticpants / Modbus

Modbus Library
0 stars 7 forks source link

TCP connection reconnects every 60s #6

Open betzrhodes opened 7 years ago

betzrhodes commented 7 years ago

Whenever I open a connection it seems to disconnect and reconnect every 60s.

Logs from code running with only an onConnect handler: 2017-05-08 15:07:24 -07:00 [Status] Downloading new code; 27.09% program storage used 2017-05-08 15:07:31 -07:00 [Device] Index : 0, value : 0 2017-05-08 15:07:31 -07:00 [Device] Index : 1, value : 0 2017-05-08 15:08:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:08:31 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:09:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:09:31 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:10:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:10:31 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:11:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:11:31 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:12:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:12:31 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:13:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:13:31 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:14:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:14:31 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:15:31 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:15:31 -07:00 [Device] Index : 1, value : 88

Logs from code running with onConnect and onReconnect handlers: 2017-05-08 15:15:43 -07:00 [Status] Downloading new code; 27.15% program storage used 2017-05-08 15:15:43 -07:00 [Status] Agent restarted: reload. 2017-05-08 15:15:52 -07:00 [Device] Index : 0, value : 28 2017-05-08 15:15:52 -07:00 [Device] Index : 1, value : 88 2017-05-08 15:16:52 -07:00 [Device] (instance : 0x534050) 2017-05-08 15:17:52 -07:00 [Device] (instance : 0x53c540) 2017-05-08 15:18:52 -07:00 [Device] (instance : 0x54a428) 2017-05-08 15:19:52 -07:00 [Device] (instance : 0x54a1c8) 2017-05-08 15:20:52 -07:00 [Device] (instance : 0x54d138) 2017-05-08 15:21:52 -07:00 [Device] (instance : 0x5362d8) 2017-05-08 15:22:52 -07:00 [Device] (instance : 0x5363c0) 2017-05-08 15:23:52 -07:00 [Device] (instance : 0x538828) 2017-05-08 15:24:52 -07:00 [Device] (instance : 0x53db20) 2017-05-08 15:25:52 -07:00 [Device] (instance : 0x535fc8) 2017-05-08 15:26:52 -07:00 [Device] (instance : 0x5472c8) 2017-05-08 15:27:52 -07:00 [Device] (instance : 0x535b30) 2017-05-08 15:28:52 -07:00 [Device] (instance : 0x535bc8)

DerrickHoPakCheung commented 7 years ago

the disconnection and reconnection are caused by the inactivity of the master after a certain amount of idle time. If the connection is busy, the connection stays open. With some PLCs, the connection timeout can be configured. Regardless, would you like to have an optional keepAlive function to keep the connection open ?

betzrhodes commented 7 years ago

Can this behavior be added to the documentation. This will help the user know what functions they need to pass in.

DerrickHoPakCheung commented 7 years ago

sure no problem