Ping gRPC Method
Parameters
count
integer
Loading...
Returns
response
integer
Loading...
Request
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"89"google.golang.org/grpc"10"google.golang.org/grpc/credentials"11"google.golang.org/grpc/metadata"1213pb "hyperliquid-grpc-go/pb"14)1516const (17// Using Quicknode endpoint18grpcEndpoint = "your-grpc-endpoint:port"19authToken = "your-auth-token"20)2122// Create gRPC connection with TLS23func createConnection() (*grpc.ClientConn, error) {24tlsConfig := &tls.Config{25InsecureSkipVerify: false, // Set to true only for testing26}27creds := credentials.NewTLS(tlsConfig)2829conn, err := grpc.Dial(30grpcEndpoint,31grpc.WithTransportCredentials(creds),32grpc.WithDefaultCallOptions(33grpc.MaxCallRecvMsgSize(100*1024*1024), // 100MB34),35)3637return conn, err38}3940// Create context with auth metadata41func createContext() context.Context {42md := metadata.Pairs("x-token", authToken)43return metadata.NewOutgoingContext(context.Background(), md)44}454647// Test connectivity48func pingTest(client pb.StreamingClient) error {49ctx := createContext()5051resp, err := client.Ping(ctx, &pb.PingRequest{Count: 1})52if err != nil {53return fmt.Errorf("ping failed: %v", err)54}5556log.Printf("✅ Ping successful: %+v", resp)57return nil58}596061func main() {62// Create connection63conn, err := createConnection()64if err != nil {65log.Fatalf("❌ Failed to connect: %v", err)66}67defer conn.Close()6869// Create client70client := pb.NewStreamingClient(conn)7172// Test connectivity73fmt.Printf("Testing connection to: %s\n", grpcEndpoint)74if err := pingTest(client); err != nil {75log.Fatalf("❌ Ping test failed: %v", err)76}7778fmt.Println("✅ Connection test completed successfully!")79}
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"89"google.golang.org/grpc"10"google.golang.org/grpc/credentials"11"google.golang.org/grpc/metadata"1213pb "hyperliquid-grpc-go/pb"14)1516const (17// Using Quicknode endpoint18grpcEndpoint = "your-grpc-endpoint:port"19authToken = "your-auth-token"20)2122// Create gRPC connection with TLS23func createConnection() (*grpc.ClientConn, error) {24tlsConfig := &tls.Config{25InsecureSkipVerify: false, // Set to true only for testing26}27creds := credentials.NewTLS(tlsConfig)2829conn, err := grpc.Dial(30grpcEndpoint,31grpc.WithTransportCredentials(creds),32grpc.WithDefaultCallOptions(33grpc.MaxCallRecvMsgSize(100*1024*1024), // 100MB34),35)3637return conn, err38}3940// Create context with auth metadata41func createContext() context.Context {42md := metadata.Pairs("x-token", authToken)43return metadata.NewOutgoingContext(context.Background(), md)44}454647// Test connectivity48func pingTest(client pb.StreamingClient) error {49ctx := createContext()5051resp, err := client.Ping(ctx, &pb.PingRequest{Count: 1})52if err != nil {53return fmt.Errorf("ping failed: %v", err)54}5556log.Printf("✅ Ping successful: %+v", resp)57return nil58}596061func main() {62// Create connection63conn, err := createConnection()64if err != nil {65log.Fatalf("❌ Failed to connect: %v", err)66}67defer conn.Close()6869// Create client70client := pb.NewStreamingClient(conn)7172// Test connectivity73fmt.Printf("Testing connection to: %s\n", grpcEndpoint)74if err := pingTest(client); err != nil {75log.Fatalf("❌ Ping test failed: %v", err)76}7778fmt.Println("✅ Connection test completed successfully!")79}