Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all SubConns are in TransientFailure #490

Closed
rhzs opened this issue Dec 1, 2017 · 11 comments
Closed

all SubConns are in TransientFailure #490

rhzs opened this issue Dec 1, 2017 · 11 comments

Comments

@rhzs
Copy link

rhzs commented Dec 1, 2017

Hi guys,

I tried to run this repo examples folder but didn't work as expected.

Step to reproduce:

  1. Install deps:
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go
  1. cd $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/examples
  2. go build && ./examples or go run main.go
  3. In another terminal window:
➜ curl -X POST \
  http://localhost:8080/v1/example/echo_body \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
        "id": "example"
}'
{"error":"all SubConns are in TransientFailure","code":14}%

I also got the same result with other endpoints POST http://localhost:8080/v1/example/echo/myid.

Any idea why I keep getting {"error":"all SubConns are in TransientFailure","code":14}%? How to make it work?

Thank you.

@rhzs
Copy link
Author

rhzs commented Dec 1, 2017

Nvm, I haven't started GRPC server

@rhzs rhzs closed this as completed Dec 1, 2017
@gusseleet
Copy link

Could you give some more information? How did you start it?

@philipithomas
Copy link
Contributor

For anybody else getting this error - I have seen it on the client if the server panics and crashes. So, for a couple seconds, the server is down until kubernetes replaces the pod. It can be confusing to find the problem because you need the logs from the crashed container.

@Emixam23
Copy link

I have this issue on Mac OS X, any idea?

@johanbrandhorst
Copy link
Collaborator

This is just indicative of the client not being able to connect to the server. Check your setup.

@Emixam23
Copy link

Ok so I did check my setup and, I found this link on internet that, even if I have others problems now, helped me to get rid of this error : https://github.com/mycodesmells/golang-examples/blob/master/grpc/cmd/server/main.go

The thing I just don't get with this example is that, the guy initialize the grpc server, half in main, half in a go routine, then he serv the http part of its server and, the only difference I see is that he initialize a part of it before the go routine instead of initializing everything inside of this go routine (I hope I am clear, english isn't my first language sorry)

@vaikzs
Copy link

vaikzs commented Apr 8, 2019

@johanbrandhorst I'm getting the same error now. I did no code change with the setup. Could you please help?

@johanbrandhorst
Copy link
Collaborator

@vaikzs I'm not sure what else I can add, this is an error returned from the gRPC client when it cannot connect to the server. Please ensure your gateway can connect to the gRPC backend.

@Emixam23
Copy link

Emixam23 commented Apr 8, 2019

@vaikzs Just as a side question, do you have any defer conn.close()? This might be where you issue comes from. Also, gRPC Gateway and gRPC server are two different instance (if I can tell so), make sure you're on different ports

@vaikzs
Copy link

vaikzs commented Apr 10, 2019

@Emixam23 @johanbrandhorst Thanks for the responses. I guess my grpc server was not running for some reason. It seems to be fine now.

@lishuhao
Copy link

The README example just start Http server, not start rpc server
This can work

func run() error {
	ctx := context.Background()
	ctx, cancel := context.WithCancel(ctx)
	defer cancel()

	// Register gRPC server endpoint
	// Note: Make sure the gRPC server is running properly and accessible
	mux := runtime.NewServeMux()
	opts := []grpc.DialOption{grpc.WithInsecure()}
	err := gw.RegisterPushServiceHandlerFromEndpoint(ctx, mux, "localhost:8888", opts)
	if err != nil {
		return err
	}

	go func() {
		listener, err := net.Listen("tcp", conf.Config.Listen)
		if err != nil {
			log.Fatalln("listen failed:", err)
		}

		rpcServer := grpc.NewServer()

		gw.RegisterPushServiceServer(rpcServer, &service.PushServer{})
		if err := rpcServer.Serve(listener); err != nil {
			log.Fatalln("serve error:", err)
		}
	}()


	// Start HTTP server (and proxy calls to gRPC server endpoint)
	return http.ListenAndServe(":9999", mux)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants