Skip to content

fix: adds ethernet event handler to GenericTcpClient to connect on li…#196

Merged
ndorin merged 2 commits intomaintenance-1xfrom
linkup-reconnect-tcp
Dec 12, 2025
Merged

fix: adds ethernet event handler to GenericTcpClient to connect on li…#196
ndorin merged 2 commits intomaintenance-1xfrom
linkup-reconnect-tcp

Conversation

@aknous
Copy link
Contributor

@aknous aknous commented Dec 12, 2025

This pull request enhances the robustness and reliability of the GenericTcpIpClient class by improving its handling of network connectivity events and connection management. The main focus is on ensuring automatic reconnection when the network link is restored, improving debug logging, and refining connection retry logic.

Network event handling and reconnection:

  • Subscribed to CrestronEnvironment.EthernetEventHandler in all constructors to handle Ethernet link events, allowing the client to attempt reconnection automatically when the network link comes back up. [1] [2] [3]
  • Added the CrestronEnvironment_EthernetEventHandler method, which listens for LinkUp events and triggers a reconnect if the TCP client exists.

Connection management improvements:

  • In the Connect method, added a debug message when creating a new TCPClient and ensured the retry timer is reset before attempting to connect.
  • In the Client_SocketStatusChange method, now stops the retry timer when the socket status changes to a connected state, preventing unnecessary retries.

Debugging and error handling:

  • Improved error logging in the ConnectToServerCallback method by logging connection failures with Debug.LogError, making it easier to diagnose connection issues.

@ndorin ndorin merged commit 28f3ca3 into maintenance-1x Dec 12, 2025
2 checks passed
@ndorin ndorin deleted the linkup-reconnect-tcp branch December 12, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants