Skip to content

Commit 832e747

Browse files
authored
Merge pull request #315 from NotoriousBIT/v4.0-dev
Check if socket is already connected
2 parents 9f0d2e5 + 5ea8c1e commit 832e747

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsmodbus",
3-
"version": "4.0.7",
3+
"version": "4.0.8",
44
"description": "Implementation for the Serial/TCP Modbus protocol.",
55
"author": "Stefan Poeter <stefan.poeter@cloud-automation.de>",
66
"main": "./dist/modbus.js",

src/tcp-client-request-handler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export default class ModbusTCPClientRequestHandler extends MBClientRequestHandle
3939

4040
this._socket.on('connect', this._onConnect.bind(this))
4141
this._socket.on('close', this._onClose.bind(this))
42+
43+
// Check if the passed in socket connection is already connected
44+
if(this._socket.readyState === 'open'){
45+
this._onConnect()
46+
}
4247
}
4348

4449
// TODO: Find a better way then putting in the any overide

0 commit comments

Comments
 (0)