Best practice for connect and close of async client #1756
-
Hi all, I am currently building a modbus client with the AsyncModbusTcpClient. The examples work very well. But I wonder, is it best practice to open and close the connection on every polling operation, like shown in the examples:
I thought it would be better to open the connection once and close the connection at a later point whenever communcation should stop. Would be great to get a hint how that could be implemented with the async client. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
of course not, see e.g. client_calls.py. You connect in the beginning and close when finished. Actually the example says that, it's modbus_calls not modbus_call I am not what sure hint you want the code is right there in the example, |
Beta Was this translation helpful? Give feedback.
-
Thanks @janiversen for your answer. |
Beta Was this translation helpful? Give feedback.
of course not, see e.g. client_calls.py.
You connect in the beginning and close when finished.
Actually the example says that, it's modbus_calls not modbus_call
I am not what sure hint you want the code is right there in the example,
1: create client
2: connect
3: run all the calls you want
4: close