iec104-python
iec104-python copied to clipboard
Python Script stops when the client is stopped without a connection
Hello. I noticed that when the commands client.stop(), client.reconnect_all(), and connection.close() are called without a valid connection between client and server, the execution of the Python script stops immediately, not running until the end.
Below is a code example that reproduces this error on my machine:
import c104
IP_ADDRESS = "10.11.1.21" # Any invalid IP
STATION_COMMON_ADDRESS = 1
if __name__ == "__main__":
client = c104.Client(tick_rate_ms=0, command_timeout_ms=5000)
connection = client.add_connection(
ip=IP_ADDRESS, port=2404, init=c104.Init.INTERROGATION
)
station = connection.add_station(common_address=STATION_COMMON_ADDRESS)
while True:
print("Loop Start")
client.start()
client.stop() # or client.reconnect_all()
print("Loop End") # This never occurs, because the script will stop at client.stop()
Tested on Python 3.10 and 3.12 with C104 1.18.0 and 1.17.1.
Thanks in advance.