Skip to content

Why does the client.DoTimeout timeout setting have no effect? #2071

@ljfuyuan

Description

@ljfuyuan

Here is my core code

client := &fasthttp.Client{
	Name: "timeout-test-client",
}

req := fasthttp.AcquireRequest()
resp := fasthttp.AcquireResponse()

defer func() {
	fasthttp.ReleaseRequest(req)
	fasthttp.ReleaseResponse(resp)
}()

req.SetRequestURI("http://aaaa.com")
req.Header.SetMethod(fasthttp.MethodPost)
req.Header.SetContentType("application/json")
req.SetBodyRaw(body)

fmt.Println("###########start", start)
if err = client.DoTimeout(req, resp, time.Second*5); err != nil {
	fmt.Println("###########end", time.Now().Sub(start))
	return false, err
}
fmt.Println("###########end", time.Now().Sub(start))

And i got this:

###########start 2025-09-19 05:23:21.961335825 +0000 UTC m=+0.000482228
###########end 32.247683172s

Why do I still get a timeout result after 30 seconds even if I set a 5-second timeout?
Did I miss any setting? Thanks you all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions