Skip to content

client timeout is 0 #14

Closed
Closed

Description

@tompscanlan

I was getting the error "context deadline exceeded" using a generated client. After some debugging, I discovered the default timeout is not affecting the call to Submit() in client/runtime.go.

request.timeout is 0 in this line:

ctx, cancel := context.WithTimeout(pctx, request.timeout)

Setting a good timeout just before that line gets me past the error.

request.SetTimeout(30 * time.Second)
ctx, cancel := context.WithTimeout(pctx, request.timeout)

Am I just using the client wrong, or is this a bug?

Activity

  1. tompscanlan commented on Sep 11, 2016

    @tompscanlan
    Author

    I think it may be a documentation bug. Docs say to try:

    transport := httptransport.New(os.Getenv("TODOLIST_HOST"), "", nil)
    client := apiclient.New(transport, strfmt.Default)
    resp, err := client.Operations.All(operations.AllParams{})
    

    But to set a timeout, you can call something like:

    transport := httptransport.New(os.Getenv("TODOLIST_HOST"), "", nil)
    client := apiclient.New(transport, strfmt.Default)
    resp, err := client.Operations.All(operations.NewAllParamsWithTimeout(30 * time.Second))
    

    That also gets me around the bug. Not sure why the default timeout isn't being honored, but this works for me.

  2. casualjim commented on Sep 11, 2016

    @casualjim
    Member

    right, and if you use operations.NewAllParams() it should already default to 30 seconds

  3. tompscanlan commented on Sep 11, 2016

    @tompscanlan
    Author

    I'm the bug... ;(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions