Skip to main content

Ping gRPC Method

Loading...

Updated on
Jan 07, 2026

Ping gRPC Method

Parameters

count
integer
Loading...

Returns

response
integer
Loading...
Request
1
package main
2
3
import (
4
"context"
5
"crypto/tls"
6
"fmt"
7
"log"
8
9
"google.golang.org/grpc"
10
"google.golang.org/grpc/credentials"
11
"google.golang.org/grpc/metadata"
12
13
pb "hyperliquid-grpc-go/pb"
14
)
15
16
const (
17
// Using Quicknode endpoint
18
grpcEndpoint = "your-grpc-endpoint:port"
19
authToken = "your-auth-token"
20
)
21
22
// Create gRPC connection with TLS
23
func createConnection() (*grpc.ClientConn, error) {
24
tlsConfig := &tls.Config{
25
InsecureSkipVerify: false, // Set to true only for testing
26
}
27
creds := credentials.NewTLS(tlsConfig)
28
29
conn, err := grpc.Dial(
30
grpcEndpoint,
31
grpc.WithTransportCredentials(creds),
32
grpc.WithDefaultCallOptions(
33
grpc.MaxCallRecvMsgSize(100*1024*1024), // 100MB
34
),
35
)
36
37
return conn, err
38
}
39
40
// Create context with auth metadata
41
func createContext() context.Context {
42
md := metadata.Pairs("x-token", authToken)
43
return metadata.NewOutgoingContext(context.Background(), md)
44
}
45
46
47
// Test connectivity
48
func pingTest(client pb.StreamingClient) error {
49
ctx := createContext()
50
51
resp, err := client.Ping(ctx, &pb.PingRequest{Count: 1})
52
if err != nil {
53
return fmt.Errorf("ping failed: %v", err)
54
}
55
56
log.Printf("✅ Ping successful: %+v", resp)
57
return nil
58
}
59
60
61
func main() {
62
// Create connection
63
conn, err := createConnection()
64
if err != nil {
65
log.Fatalf("❌ Failed to connect: %v", err)
66
}
67
defer conn.Close()
68
69
// Create client
70
client := pb.NewStreamingClient(conn)
71
72
// Test connectivity
73
fmt.Printf("Testing connection to: %s\n", grpcEndpoint)
74
if err := pingTest(client); err != nil {
75
log.Fatalf("❌ Ping test failed: %v", err)
76
}
77
78
fmt.Println("✅ Connection test completed successfully!")
79
}
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free