Tomcat server not working along with gRPC server
Hi, I am using grpc-spring-boot-starter. gRPC server is working fine but the tomcat server is not working because of which slf4j logging and actuator endpoints aren't working. For actuator I went through this github page by the author - https://yidongnan.github.io/grpc-spring-boot-starter/en/actuator.html but this is also not working... How this can be resolved ?
Currently there is not grpc actuator endpoint so you have to use the webserver/tomcat for that. The actuator page only shows how you can modify what is shown/reported to springs actuator endpoint.
How this can be resolved ?
Please always include a stacktrace, otherwise we cannot help you.
I am running into similar issue when I am enabling actuator with embedded tomcat in my spring-boot application.
I noticed the tomcat is running on the grpc service port 50051 even thought I have explicitly specified both the server.port and grpc.server.port to run on different ports. The gRPC service fails complaining about the address being already in use.
I have tried with embedded Jetty server too and ran into the same issue where the Jetty server is running on the gRPC service port even though they are configured to run on different ports.
Check the logs below
server:
port: 8080
grpc:
server:
port: 50051
2022-06-14 22:52:09.478 DEBUG 8 --- [ main] o.apache.tomcat.util.IntrospectionUtils : IntrospectionUtils: setProperty(class org.apache.coyote.http11.Http11NioProtocol port=50051)
2022-06-14 22:52:09.772 INFO 8 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 50051 (http)
2022-06-14 22:52:20.177 DEBUG 8 --- [-50051-Acceptor] o.apache.tomcat.util.threads.LimitLatch : Counting up[http-nio-50051-Acceptor] latch=0
2022-06-14 22:52:20.179 INFO 8 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 50051 (http) with context path ''
Thats a very odd issue. I never had this issue before and I use tomcat and grpc and actuator for years now.
Is one of your active profiles named grpc? Do you have an external config provider? Which version of spring-boot are you using? How does the grpc-server react in this case? Which port does the grpc server try to use? Doesnt it log a port already in use? Could you debug the GrpcServerLifecycle#start method whether it throws?
You could use the actuator configprops/env(?) endpoint to locate why the server.port property is set to that value (see origin).