fix openclaw gateway connect timeout

This commit is contained in:
Haitao Pan 2026-05-15 12:10:31 +08:00
parent 68df669576
commit ce1de28896
2 changed files with 31 additions and 0 deletions

View File

@ -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

View File

@ -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()