From ace96191fe1f4815687dfed1b554f2493120d1d5 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Fri, 1 May 2020 14:59:50 +0100 Subject: [PATCH] force codec on call not on dial (#1599) --- grpc.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grpc.go b/grpc.go index e25f3dd..1932f9c 100644 --- a/grpc.go +++ b/grpc.go @@ -129,7 +129,6 @@ func (g *grpcClient) call(ctx context.Context, node *registry.Node, req client.R var grr error grpcDialOptions := []grpc.DialOption{ - grpc.WithDefaultCallOptions(grpc.ForceCodec(cf)), grpc.WithTimeout(opts.DialTimeout), g.secure(address), grpc.WithDefaultCallOptions( @@ -154,7 +153,9 @@ func (g *grpcClient) call(ctx context.Context, node *registry.Node, req client.R ch := make(chan error, 1) go func() { - grpcCallOptions := []grpc.CallOption{grpc.CallContentSubtype(cf.Name())} + grpcCallOptions := []grpc.CallOption{ + grpc.ForceCodec(cf), + grpc.CallContentSubtype(cf.Name())} if opts := g.getGrpcCallOptions(); opts != nil { grpcCallOptions = append(grpcCallOptions, opts...) } @@ -213,7 +214,6 @@ func (g *grpcClient) stream(ctx context.Context, node *registry.Node, req client wc := wrapCodec{cf} grpcDialOptions := []grpc.DialOption{ - grpc.WithDefaultCallOptions(grpc.ForceCodec(wc)), grpc.WithTimeout(opts.DialTimeout), g.secure(address), } @@ -233,7 +233,10 @@ func (g *grpcClient) stream(ctx context.Context, node *registry.Node, req client ServerStreams: true, } - grpcCallOptions := []grpc.CallOption{grpc.CallContentSubtype(cf.Name())} + grpcCallOptions := []grpc.CallOption{ + grpc.ForceCodec(wc), + grpc.CallContentSubtype(cf.Name()), + } if opts := g.getGrpcCallOptions(); opts != nil { grpcCallOptions = append(grpcCallOptions, opts...) }