From ce1de288964de2efccf0f07ac29afa3415fef816 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Fri, 15 May 2026 12:10:31 +0800 Subject: [PATCH] fix openclaw gateway connect timeout --- internal/acp/gateway.go | 14 ++++++++++++++ internal/acp/gateway_runtime_test.go | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/internal/acp/gateway.go b/internal/acp/gateway.go index 61e2cca..e71edae 100644 --- a/internal/acp/gateway.go +++ b/internal/acp/gateway.go @@ -10,6 +10,11 @@ import ( "xworkmate-bridge/internal/shared" ) +const ( + productionOpenClawGatewayConnectTimeout = 60 * time.Second + productionOpenClawGatewayChallengeTimeout = 30 * time.Second +) + func (s *Server) handleGatewayMethod(ctx context.Context, method string, params map[string]any, notify func(map[string]any)) (map[string]any, *shared.RPCError) { switch method { case "xworkmate.gateway.connect": @@ -194,6 +199,7 @@ func ensureProductionGatewayConnected( if server.gateway == nil { server.gateway = gatewayruntime.NewManager() } + configureProductionOpenClawGatewayRuntime(server.gateway) request := applyProductionGatewayRouting( server, @@ -226,4 +232,12 @@ func ensureProductionGatewayConnected( return &shared.RPCError{Code: -32002, Message: "GATEWAY_CONNECT_FAILED: " + message} } +func configureProductionOpenClawGatewayRuntime(manager *gatewayruntime.Manager) { + if manager == nil { + return + } + manager.ConnectTimeout = productionOpenClawGatewayConnectTimeout + manager.ChallengeTimeout = productionOpenClawGatewayChallengeTimeout +} + // Helper functions are now in helpers.go diff --git a/internal/acp/gateway_runtime_test.go b/internal/acp/gateway_runtime_test.go index f67fa90..500bb71 100644 --- a/internal/acp/gateway_runtime_test.go +++ b/internal/acp/gateway_runtime_test.go @@ -6,6 +6,23 @@ import ( "xworkmate-bridge/internal/gatewayruntime" ) +func TestConfigureProductionOpenClawGatewayRuntimeUsesLongHandshakeWindows( + t *testing.T, +) { + t.Parallel() + + manager := gatewayruntime.NewManager() + + configureProductionOpenClawGatewayRuntime(manager) + + if got := manager.ConnectTimeout; got != productionOpenClawGatewayConnectTimeout { + t.Fatalf("ConnectTimeout = %s, want %s", got, productionOpenClawGatewayConnectTimeout) + } + if got := manager.ChallengeTimeout; got != productionOpenClawGatewayChallengeTimeout { + t.Fatalf("ChallengeTimeout = %s, want %s", got, productionOpenClawGatewayChallengeTimeout) + } +} + func TestResolveGatewayReportedRemoteAddressUsesBuiltInOpenClawEndpoint(t *testing.T) { t.Parallel()