You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modbus Hardware: Phoenix Contact AXL F BK ETH via UDP/TCP
Pymodbus Specific
Client: tcp/udp - async (reconnect not applicable to sync)
Description
The client parameter/method on_reconnect_callback suggested in #1354 and implemented in #1425 is never executed in the current version of pymodbus. I believe this client parameter is unimplemented in the current version and failed to find any execution of the client.on_reconnect_callback method in the current pymodbus codebase or test suite. I attempted to use this callback to notify another async application of the failed connection, however, I could not trigger the callback in simulated/physical testing.
Code
frompymodbus.clientimportAsyncModbusTcpClientfrompymodbusimportpymodbus_apply_logging_configimportasyncioCOMMAND_REGISTER=2006RESET_COMMAND=0x8F00HOST="w.x.y.z"PORT=502CALLBACK_USED=Falsedefreconnect_callback():
CALLBACK_USED=Trueprint("Reconnect callback called!")
asyncdefcall_device_restart(client: AsyncModbusTcpClient):
""" Executes a reset command for a Phoenix-contact AXL-F device. Simulates disconnection, on_reconnect_callback is never called. """awaitclient.write_register(COMMAND_REGISTER, value=RESET_COMMAND)
asyncdefrun_client():
client=AsyncModbusTcpClient(HOST, PORT, on_reconnect_callback=reconnect_callback)
awaitclient.connect()
assertclient.connectedprint(f"Client Connected to {HOST}:{PORT}")
print("Restarting Client")
awaitcall_device_restart(client)
awaitasyncio.sleep(10)
ifnotCALLBACK_USED:
print("ERROR: Reconnect callback never called.")
if__name__=="__main__":
pymodbus_apply_logging_config("DEBUG")
print("Starting Client.")
asyncio.run(run_client(), debug=True)
print("Script Done.")
Logs
Starting Client.
2024-01-30 20:54:41,492 DEBUG logging:103 Connecting to w.x.y.z:502.
2024-01-30 20:54:41,493 DEBUG logging:103 Connecting comm
2024-01-30 20:54:41,500 DEBUG logging:103 Connected to comm
2024-01-30 20:54:41,500 DEBUG logging:103 callback_connected called
Client Connected to 169.254.0.13:502
Restarting Client
2024-01-30 20:54:41,503 DEBUG logging:103 send: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x6 0x7 0xd6 0x8f 0x0
2024-01-30 20:54:41,506 DEBUG logging:103 Adding transaction 1
2024-01-30 20:54:41,508 DEBUG logging:103 recv: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x6 0x7 0xd6 0x8f 0x0 old_data: addr=None
2024-01-30 20:54:41,508 DEBUG logging:103 Processing: 0x0 0x1 0x0 0x0 0x0 0x6 0x0 0x6 0x7 0xd6 0x8f 0x0
2024-01-30 20:54:41,509 DEBUG logging:103 Factory Response[WriteSingleRegisterResponse': 6]
2024-01-30 20:54:41,509 DEBUG logging:103 Getting transaction 1
2024-01-30 20:54:46,788 DEBUG logging:103 Connection lost comm due to [WinError 1236] The network connection was aborted by the local system
2024-01-30 20:54:46,790 DEBUG logging:103 Wait comm 100.0 ms before reconnecting.
2024-01-30 20:54:46,892 DEBUG logging:103 Connecting comm
2024-01-30 20:54:46,896 WARNING logging:109 Failed to connect [WinError 1232] The network location cannot be reached. For information about network troubleshooting, see Windows Help
2024-01-30 20:54:46,897 DEBUG logging:103 Wait comm 200.0 ms before reconnecting.
2024-01-30 20:54:47,100 DEBUG logging:103 Connecting comm
2024-01-30 20:54:47,104 WARNING logging:109 Failed to connect [WinError 1232] The network location cannot be reached. For information about network troubleshooting, see Windows Help
2024-01-30 20:54:47,105 DEBUG logging:103 Wait comm 400.0 ms before reconnecting.
2024-01-30 20:54:47,508 DEBUG logging:103 Connecting comm
2024-01-30 20:54:47,512 WARNING logging:109 Failed to connect [WinError 1232] The network location cannot be reached. For information about network troubleshooting, see Windows Help
2024-01-30 20:54:47,513 DEBUG logging:103 Wait comm 800.0 ms before reconnecting.
2024-01-30 20:54:48,314 DEBUG logging:103 Connecting comm
2024-01-30 20:54:48,318 WARNING logging:109 Failed to connect [WinError 1232] The network location cannot be reached. For information about network troubleshooting, see Windows Help
2024-01-30 20:54:48,319 DEBUG logging:103 Wait comm 1600.0 ms before reconnecting.
2024-01-30 20:54:49,920 DEBUG logging:103 Connecting comm
2024-01-30 20:54:49,924 WARNING logging:109 Failed to connect [WinError 1232] The network location cannot be reached. For information about network troubleshooting, see Windows Help
2024-01-30 20:54:49,925 DEBUG logging:103 Wait comm 3200.0 ms before reconnecting.
ERROR: Reconnect callback never called.
Script Done.
The text was updated successfully, but these errors were encountered:
Versions
Pymodbus Specific
Description
The client parameter/method on_reconnect_callback suggested in #1354 and implemented in #1425 is never executed in the current version of pymodbus. I believe this client parameter is unimplemented in the current version and failed to find any execution of the client.on_reconnect_callback method in the current pymodbus codebase or test suite. I attempted to use this callback to notify another async application of the failed connection, however, I could not trigger the callback in simulated/physical testing.
Code
Logs
The text was updated successfully, but these errors were encountered: