Skip to content
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

proxy: retrying POST request failed with http: invalid Read on closed Body #1229

Closed
wuyongxiu opened this issue Oct 31, 2016 · 0 comments
Closed
Assignees
Labels
bug 🐞 Something isn't working

Comments

@wuyongxiu
Copy link

(Are you asking for help with using Caddy? Please use our forum instead: https://forum.caddyserver.com. If you are filing a bug report, please answer the following questions. If your issue is not a bug report, you do not need to use this template. Either way, please consider donating if we've helped you. Thanks!)

1. What version of Caddy are you running (caddy -version)?

I tested the newest master caddy today.

2. What are you trying to do?

I try to test the proxy with POST method and body. When proxying to backend servers with load balance policy, if an error happened such as the backend server doesn't work well caddy would request another backend server.
And I add one log in following location.
res, err := transport.RoundTrip(outreq)
if err != nil {
log.Println("err:", err)
return err
}

While if this failing request is a POST request and whose body has data, the second try would fail either because of the error "http: invalid Read on closed Body" even if the backend server is normal and it should be forwarded successfully in this second try.

3. What is your entire Caddyfile?

localhost:2018

proxy / 192.168.206.231:9606 localhost:9608{
        policy round_robin
        max_fails 5
        try_interval 60s
}

PS: 192.168.206.231:9606 workes well while localhost:9608 doesn't exist.

4. How did you run Caddy (give the full command and describe the execution environment)?

OS: win7 x64
go version: go1.7
First I "go install" the source and then cd /bin directory, finally I run the caddy command
image

5. What did you expect to see?

I expect to see caddy can proxy successfully if I configure several endpoints even if there are some wrong endpoints.

6. What did you see instead (give full error messages and/or log)?

I got the log "err: http: invalid Read on closed Body"
image

7. How can someone who is starting from scratch reproduce this behavior as minimally as possible?

I have Googled this issue and found an extremely similar one. They have solved this.
flynn/flynn#872

@tpng tpng added the bug 🐞 Something isn't working label Oct 31, 2016
@tpng tpng changed the title http: invalid Read on closed Body proxy: retrying POST request failed with http: invalid Read on closed Body Oct 31, 2016
@tpng tpng self-assigned this Nov 1, 2016
tw4452852 added a commit that referenced this issue Nov 8, 2016
proxy: record request Body for retry (fixes #1229)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants