Skip to content

Document how to have a separate idle and read timeout#87

@nhooyr

Description

@nhooyr
funcread(ctx context.Context, c*websocket.Conn) ([]byte, error){ctx, cancel:=context.WithTimeout(ctx, time.Minute*30) defercancel() _, r, err:=c.Reader(ctx) iferr!=nil{returnnil, err } // One minute max to read the received message.time.AfterFunc(time.Minute, cancel) returnioutil.ReadAll(r) }

That code should be good in an example under Reader.

Related #86

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions