Send gRPC requests without authentication

Sends a request without authentication using a gRPC connection.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample

Go


import (
	"context"
	"time"

	pb "github.com/GoogleCloudPlatform/golang-samples/run/grpc-ping/pkg/api/v1"
	"google.golang.org/grpc"
)

// pingRequest sends a new gRPC ping request to the server configured in the connection.
func pingRequest(conn *grpc.ClientConn, p *pb.Request) (*pb.Response, error) {
	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancel()

	client := pb.NewPingServiceClient(conn)
	return client.Send(ctx, p)
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser