Implement connection timeout handling and improve connection cleanup in SmartProxy

This commit is contained in:
Juergen Kunz
2025-06-06 23:34:50 +00:00
parent 311691c2cc
commit 9aebcd488d
5 changed files with 604 additions and 6 deletions

View File

@ -69,6 +69,7 @@ export interface ISmartProxyOptions {
maxVersion?: string;
// Timeout settings
connectionTimeout?: number; // Timeout for establishing connection to backend (ms), default: 30000 (30s)
initialDataTimeout?: number; // Timeout for initial data/SNI (ms), default: 60000 (60s)
socketTimeout?: number; // Socket inactivity timeout (ms), default: 3600000 (1h)
inactivityCheckInterval?: number; // How often to check for inactive connections (ms), default: 60000 (60s)

View File

@ -1125,6 +1125,7 @@ export class RouteConnectionHandler {
const targetSocket = createSocketWithErrorHandler({
port: finalTargetPort,
host: finalTargetHost,
timeout: this.settings.connectionTimeout || 30000, // Connection timeout (default: 30s)
onError: (error) => {
// Connection failed - clean up everything immediately
// Check if connection record is still valid (client might have disconnected)