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

connection error occurs if the grpc server restarts #1547

Closed
hudingchen opened this issue Jul 23, 2020 · 1 comment
Closed

connection error occurs if the grpc server restarts #1547

hudingchen opened this issue Jul 23, 2020 · 1 comment

Comments

@hudingchen
Copy link

func main() {
	flag.Parse()
	defer glog.Flush()

	if err := runBookService(); err != nil {
		glog.Fatal(err)
	}
}

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

	mux := runtime.NewServeMux()
	opts := []grpc.DialOption{grpc.WithInsecure()}
	err := book_gw.RegisterBookServiceHandlerFromEndpoint(ctx, mux, *bookEndpoint, opts)
	if err != nil {
		return err
	}

	return http.ListenAndServe(":8080", mux)
}

When the grpc service restarts, the request is sent to grpc-gateway again, and the following error occurs:

{
    "error": "connection error: desc = \"transport: Error while dialing dial tcp 127.0.0.1:50052: connectex: No connection could be made because the target machine actively refused it.\"",
    "code": 14,
    "message": "connection error: desc = \"transport: Error while dialing dial tcp 127.0.0.1:50052: connectex: No connection could be made because the target machine actively refused it.\""
}
@johanbrandhorst
Copy link
Collaborator

gRPC transparently retries connections in the background, the error you're seeing here implies that the server refused the reconnection. It's not related to the gRPC gateway, this is a generic client error. If you need more help, maybe join the #grpc or #grpc-gateway channel on Gophers slack?

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

2 participants