Client-side, io.EOF is returned directly from grpc-go steram.Send() calls when the server closes the stream. At that point, Recv() should be called until it returns a non-nil error to receive the server's messages and eventually the status. If io.EOF is returned by Recv(), that indicates a success; otherwise that is the final status of the RPC. All errors are permanent from the standpoint of that stream -- subsequent streams are possible using the same client, even if it is a connection error, as the client automatically attempts to reconnect. Make sure you always call Recv() on the stream until you get a non-nil error or cancel the context used when creating the stream, or else a goroutine and other resources will be leaked.
Let me know if you have any further questions. Thanks, Doug On Tuesday, February 13, 2018 at 6:05:50 AM UTC-8, Glyn Normington wrote: > > I'm trying to decide how to handle stream errors correctly, both in the > client and in the server. My working assumption, in Go, is that io.EOF > indicates > a normal termination and that all other errors are abnormal and permanent, > but I'd like to check that assumption. > > It would be great to know which gRPC errors are permanent and which, if > any, are transient. The Go Stream > <https://godoc.org/google.golang.org/grpc#Stream> interface talks about > streams being "done" or "aborted" (both of which sound like permanent > states), but without defining these terms further. > > The available example code isn't particularly useful as it's not clear > which parts are normative. > > The gRPC documentation has a section on error handling > <https://grpc.io/docs/guides/error.html>, but this doesn't describe which > errors are permanent and which are transient. It's not even clear how the > status codes described map to language-specific error values. For instance, > which value(s) corresponds to io.EOF (surely a permanent error!) in Go? > > Please could someone offer some definitive information? > > Regards, > Glyn > > > > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To post to this group, send email to grpc-io@googlegroups.com. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/472bd15c-c2de-48ce-bf0c-33c9807eb685%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.