diff --git a/charts/tim-api/templates/httproute.yaml b/charts/tim-api/templates/httproute.yaml index 05d514a32..556939c9e 100644 --- a/charts/tim-api/templates/httproute.yaml +++ b/charts/tim-api/templates/httproute.yaml @@ -25,6 +25,15 @@ spec: {{- range .Values.gateway.httpRoute.rules }} - matches: {{- toYaml .matches | nindent 8 }} + {{- if .timeouts }} + timeouts: + {{- if .timeouts.request }} + request: {{ .timeouts.request }} + {{- end }} + {{- if .timeouts.backendRequest }} + backendRequest: {{ .timeouts.backendRequest }} + {{- end }} + {{- end }} backendRefs: {{- range .backendRefs }} - group: "" diff --git a/charts/tim-api/values.yaml b/charts/tim-api/values.yaml index 71dfd3fcd..d0c05c6b4 100644 --- a/charts/tim-api/values.yaml +++ b/charts/tim-api/values.yaml @@ -268,6 +268,11 @@ gateway: - path: type: PathPrefix value: / + # Timeout configuration for streaming endpoints + # Set to 0s to disable timeouts (recommended for SSE/streaming) + timeouts: + request: 0s # Total request timeout (0s = no timeout) + backendRequest: 0s # Backend request timeout (0s = no timeout) backendRefs: - port: 3000 # Should match service.ports[0].port (external API) weight: 1 diff --git a/tim-api/cmd/root.go b/tim-api/cmd/root.go index 81feacd92..55903f1c9 100644 --- a/tim-api/cmd/root.go +++ b/tim-api/cmd/root.go @@ -62,15 +62,16 @@ func run(cmd *cobra.Command, args []string) error { } // Create external HTTP server + // External server needs longer timeouts for streaming responses externalAddr := cfg.ExternalServer.Addr + ":" + cfg.ExternalServer.Port externalHTTPServer := &http.Server{ Addr: externalAddr, Handler: externalSrv, - ReadTimeout: 30 * time.Second, + ReadTimeout: 5 * time.Minute, // Longer for streaming responses ReadHeaderTimeout: 10 * time.Second, - WriteTimeout: 30 * time.Second, - IdleTimeout: 120 * time.Second, - MaxHeaderBytes: 1 << 20, // 1 MB + WriteTimeout: 0, // No timeout for streaming writes (SSE) + IdleTimeout: 5 * time.Minute, // Longer for persistent connections + MaxHeaderBytes: 1 << 20, // 1 MB } // Create internal HTTP server