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
net/http: expose dialing errors from net package #23827
Comments
@szuecs just to make it clear, the Running this example locally produce:
so the "connection refused" returned by Dial definitely implements net.Error interface. |
If you got the error from net.Dial, it was due to establishing the connection. If you got the error from Read or Write, it was from an already established connection. It seems that your bug report is actually about net/http, not about the net package, as stated in your bug title. Marking this as a duplicate of #14203. |
FYI: I changed my example code to show the problem more clearly. @artyom, @bradfitz maybe it's more a documentation issue for the meaning of Temporary(). My tests can not show, that Temporary fails, but it seems a bit weird to me. I also looked into the Go src code in $GOROOT and I see there some cases, which I would do a retry, for example tlsHandshakeTimeoutError is retrieable from the point of layer7 protocols view, but returns true in Temporary():
In general it's not only about "connection refused", here some other examples with a backend socat-test and logs from running the go code: slow backend (see the $(sleep 1) that is the value for header X-Foo):
client logs for slow backend:
client logs without having a backend
middlebox that silently drop packets (iptables -I INPUT -p tcp --dst 127.0.0.1 --dport 10000 -j DROP)
test tls handshake failuresTBD |
I would like to get meaningful errors from the net package. Right now I can not decide if I got an error while a connection is already established or if it's while creating a TCP or TLS handshake.
I want to be able to decide from an error, if I can retry the call or not. Possibly net.Error interface has to get a new function to decide this easily.
The code shows a workaround wrapping a net.Dialer to decide if the error happened was during Dial or an already established connection.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
I would like to do:
What did you see instead?
net.Error has Temporary() and Timeout() defined and rest of the errors are "untyped" fmt.Errorf("connection refused").
I would like to be able to dispatch by retrieable error. In an http proxy/loadbalancer this means you want to decide if you sent data or not, because if you already sent data, you should not retry.
I have to built a workaround as shown above in zalando/skipper@d3fa9e9 .
The text was updated successfully, but these errors were encountered: