Why grpc-go can run grpc server and http server at the same address and port, but grpc-node cannot
I had read this answer: https://stackoverflow.com/a/56943771/6463558, it says that there is no way to run gRPC server and HTTP server at same address and port using grpc-node package. But I can create gRPC server and HTTP server at same address and port(e.g. both using localhost:3000) using grpc-go package. Here is an example: https://github.com/mrdulin/grpc-go-cnode/blob/master/cmd/server/main.go#L79 So, why grpc-node and grpc-go behave inconsistently. Does this make sense? The result I expect is that no matter what language is implemented in grpc, the behavior should be consistent. So the grpc server should be able to share the same port with the server created by Node's standard library http in same system process.
It is all about implementation. Each language has its own implementation for gRPC. There are many differences from each language implementation, some due to language capability but also due to the maintainers. Each project is a different project. In this case, we can not really say that gRPC and HTTP servers are sharing the same address. There is only the HTTP server running. However, Golang implementation for gRPC server has an option to serv the gRPC through HTTP. Calling server.ServeHTTP() instead of server.Serve() That is possible because, under the hood, gRPC server is built on top HTTP2 This snippet from the link you shared make what I said clear if request.ProtoMajor != 2 { mux.ServeHTTP(writer, request) return } if strings.Contains(request.Header.Get("Content-Type"), "application/grpc") { grpcServer.ServeHTTP(writer, request) return } If you want to do the same in Node, you need to check in the grpc-node implementation if there is such a thing available
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/14ebda3d7c6bead7adf7f85eb67c5e71f46a42510eef94b5cc9025ca33b0a19f