Closed
Description
What version of gRPC are you using?
v1.71.0
What version of Go are you using (go version
)?
go version go1.24.2 linux/amd64
What operating system (Linux, Windows, …) and version?
Linux
What did you do?
package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/resolver"
)
// testResolver is a dummy resolver that always resolves to a static address.
type testResolver struct{}
func (testResolver) Scheme() string {
return "test"
}
func (r testResolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
cc.UpdateState(resolver.State{
Addresses: []resolver.Address{
{Addr: "10.1.1.1:1234"},
},
})
return r, nil
}
func (testResolver) ResolveNow(_ resolver.ResolveNowOptions) {}
func (testResolver) Close() {}
func init() {
resolver.Register(testResolver{})
}
func main() {
cc, err := grpc.NewClient("test://",
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
panic(err)
}
defer cc.Close()
c := grpc_health_v1.NewHealthClient(cc)
res, err := c.Check(context.Background(), &grpc_health_v1.HealthCheckRequest{})
if err != nil {
panic(err)
}
fmt.Println(res)
}
Execute under the following environment:
https_proxy=http://localhost:8080 NO_PROXY=10.0.0.0/8 go run .
What did you expect to see?
Behavior v1.70.0 and below was that, because the resolved address 10.1.1.1:1234 matched NO_PROXY=10.0.0.0/8
, the proxy would not be used.
What did you see instead?
gRPC as of v1.71.0 (specifically #7881) now attempts to use a proxy for the outbound connection to 10.1.1.1:1234
.
panic: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:8080: connect: connection refused"
This represents a change in behavior from v1.70.0 and below. It also means there is no way to use NO_PROXY
to bypass proxies for custom resolvers.