Skip to content

Commit b0fa1e2

Browse files
authored
Merge branch 'main' into julien/simplify-store
2 parents 0124c25 + 5506eb0 commit b0fa1e2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

execution/grpc/client.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package grpc
22

33
import (
44
"context"
5+
"crypto/tls"
56
"fmt"
7+
"net"
68
"net/http"
79
"time"
810

911
"connectrpc.com/connect"
12+
"golang.org/x/net/http2"
1013
"google.golang.org/protobuf/types/known/timestamppb"
1114

1215
"github.com/evstack/ev-node/core/execution"
@@ -23,6 +26,20 @@ type Client struct {
2326
client v1connect.ExecutorServiceClient
2427
}
2528

29+
// newHTTP2Client creates an HTTP/2 client that supports cleartext (h2c) connections.
30+
// This is required to connect to native gRPC servers without TLS.
31+
func newHTTP2Client() *http.Client {
32+
return &http.Client{
33+
Transport: &http2.Transport{
34+
AllowHTTP: true,
35+
DialTLSContext: func(ctx context.Context, network, addr string, _ *tls.Config) (net.Conn, error) {
36+
var d net.Dialer
37+
return d.DialContext(ctx, network, addr)
38+
},
39+
},
40+
}
41+
}
42+
2643
// NewClient creates a new gRPC execution client.
2744
//
2845
// Parameters:
@@ -32,9 +49,11 @@ type Client struct {
3249
// Returns:
3350
// - *Client: The initialized gRPC client
3451
func NewClient(url string, opts ...connect.ClientOption) *Client {
52+
// Prepend WithGRPC to use the native gRPC protocol (required for tonic/gRPC servers)
53+
opts = append([]connect.ClientOption{connect.WithGRPC()}, opts...)
3554
return &Client{
3655
client: v1connect.NewExecutorServiceClient(
37-
http.DefaultClient,
56+
newHTTP2Client(),
3857
url,
3958
opts...,
4059
),

0 commit comments

Comments
 (0)