-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clientDoDeadline maybe timeout before deadline #1071
Comments
That's not how The time you pass to DoDeadline can also be different from your ReadTimeout or WriteTimeout. |
Thank's for your answer. I found that I have miss the loop in HostClient.Do which invokes HostClient.do. But i still found that DoDeadline may timeout before deadline when the request method is POST. When i use a client with ReadTimeout=1s, and now i use client.DoDeadline(req, rsp, 10s) which i want to wait for 10s to receive response. It will wait for 10s only when reqeust method is one of Get/Put/Head, because those methods are retryable.
when the request method is POST, it will returns after 1s, because POST is not retryable by default. |
Actually, I was wrong. Deadlines aren't reset each time a packet arrives. But I still don't see the issue. The idea is that you can set You can for example set:
Which would work for requests that take 2 seconds write and 2 seconds to read. But wouldn't work for requests that take 3 seconds to write and 3 seconds to read. I'm not sure why you are setting |
@erikdubbelboer Sometimes we will reuse a client for many requests. We will set ReadTimeout=5s, WriteTimeout=5s by default. Once an POST request need longer deadline, it will use Client.DoDeadline instead of client.Do, and set deadline to such as 30 seconds。But the request will still timeout after 5 seconds because clientDoDeadline will not retry for POST. |
That's not how it works I'm afraid. I also don't like the But maybe we should mark them as deprecated and add |
@erikdubbelboer overwrite ReadTimeout and WriteTimeout is a good idea, it can fix the problem. |
Just an initial idea: #1096 |
@erikdubbelboer Thanks! |
client.go clientDoDeadline routinue (G0) raise a routinue (G1) to recive response, and start a new timer according to deadline。G0 will wait for response and timer。But the connection for reading response will timeout before the deadline, because the connection will be set deadline when client's ReadTimeout/WriteTimeout is set.
The text was updated successfully, but these errors were encountered: