How proxy connection monitoring and recovery works
mainThe proxy maintains connection resilience using a ping/pong mechanism to monitor the target service.
- Detection: If a pong response from the target does not arrive within the expected timeframe, the proxy considers the connection failed, closes it, and initiates a reconnection attempt. This handles cases where the target is unresponsive (e.g., due to an event loop block) even if the TCP connection is technically still open.
- Recovery: The proxy detects connection loss regardless of whether the target service crashes gracefully or abruptly, and automatically attempts to reconnect.
- Client Stability: The connection between the client and the proxy remains stable even when the connection between the proxy and the target is being recovered.
This mechanism is useful for integrating with services that may experience intermittent freezes or restarts.