Skip to content

[Question] Allow excluding SSE/WebSocket from http.Timeout in Kratos HTTP server #3775

@zongjiye

Description

@zongjiye

Hi,

In my Kratos HTTP server, I configure the timeout like this:
if c.Http.Timeout != nil { opts = append(opts, http.Timeout(c.Http.Timeout.AsDuration())) }
As far as I can tell, this timeout is applied at the whole server level and affects all routes.

However, I don’t want this timeout to apply to SSE (Server-Sent Events) and WebSocket connections, since those are long-lived streams by design. I’ve tried several approaches to exclude those endpoints from the timeout, but haven’t been able to make it work.

Is there a recommended way to:

disable http.Timeout for specific routes, or

skip SSE/WebSocket requests when applying the timeout, or

otherwise configure different timeout behavior for streaming connections?

If this is not currently supported, would you consider adding a way to exclude certain routes or connection types (SSE / WebSocket) from the global http.Timeout?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions