Hello Nikhli, have you solved the issue?

вторник, 17 января 2017 г., 6:36:13 UTC+3 пользователь Nikhil Tathe написал:
>
> Hi all,
> I am building a grpc server client communication on windows.
> I am getting error as 
> transport: http2Server.HandleStreams failed to read frame: read tcp 
> 192.168.56.1:8080->192.168.56.1:29065: wsarecv: An existing connection 
> was forcibly closed by the remote host.
> I am not able understand it.
> I googled about it but I no luck.
>
> I tried grpc sample code from 
> https://github.com/grpc/grpc-go/tree/master/examples/helloworld/ on my 
> system
> still getting similar error
> transport: http2Server.HandleStreams failed to read frame: read tcp [::1]:
> 50051->[::1]:28563: wsarecv: An existing connection was forcibly closed by 
> the remote host.
>
> Server code:
> package main
>
> import (
>     "log"
>     "net"
>
>     "golang.org/x/net/context"
>     "google.golang.org/grpc"
>     pb "google.golang.org/grpc/examples/helloworld/helloworld"
>     "google.golang.org/grpc/reflection"
> )
>
> const (
>     port = ":50051"
> )
>
> // server is used to implement helloworld.GreeterServer.
> type server struct{}
>
> // SayHello implements helloworld.GreeterServer
> func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.
> HelloReply, error) {
>     return &pb.HelloReply{Message: "Hello " + in.Name}, nil
> }
>
> func main() {
>     lis, err := net.Listen("tcp", port)
>     if err != nil {
>         log.Fatalf("failed to listen: %v", err)
>     }
>     s := grpc.NewServer()
>     pb.RegisterGreeterServer(s, &server{})
>     // Register reflection service on gRPC server.
>     reflection.Register(s)
>     if err := s.Serve(lis); err != nil {
>         log.Fatalf("failed to serve: %v", err)
>     }
> }
>
> Client code 
> package main
>
> import (
>     "log"
>     "os"
>
>     "golang.org/x/net/context"
>     "google.golang.org/grpc"
>     pb "google.golang.org/grpc/examples/helloworld/helloworld"
> )
>
> const (
>     address     = "localhost:50051"
>     defaultName = "world"
> )
>
> func main() {
>     // Set up a connection to the server.
>     conn, err := grpc.Dial(address, grpc.WithInsecure())
>     if err != nil {
>         log.Fatalf("did not connect: %v", err)
>     }
>     defer conn.Close()
>     c := pb.NewGreeterClient(conn)
>
>     // Contact the server and print out its response.
>     name := defaultName
>     if len(os.Args) > 1 {
>         name = os.Args[1]
>     }
>     r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: name
> })
>     if err != nil {
>         log.Fatalf("could not greet: %v", err)
>     }
>     log.Printf("Greeting: %s", r.Message)
> }
>
>
> I found something on googling as 
> https://go.googlesource.com/net/+/master/http2/server.go
> https://golang.org/src/net/http/h2_bundle.go
>
> which tells problem is Windows OS specific.
> Not able to understand and find solution for it.
>
> if runtime.GOOS == "windows" {
>
>         if oe, ok := err.(*net.OpError); ok && oe.Op == "read" {
>
>             if se, ok := oe.Err.(*os.SyscallError); ok && se.Syscall == 
> "wsarecv" {
>
>                 const WSAECONNABORTED = 10053
>
>                 const WSAECONNRESET = 10054
>
>                 if n := http2errno(se.Err); n == WSAECONNRESET || n == 
> WSAECONNABORTED {
>
>                     return true
>
>                 }
>
>             }
>
>         }
>
>     }
>
>
> Can anyone help me out in it ?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to