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

Grpc server started but cannot connect #588

Closed
jeffreychuuu opened this issue Sep 28, 2021 · 7 comments
Closed

Grpc server started but cannot connect #588

jeffreychuuu opened this issue Sep 28, 2021 · 7 comments
Labels
feedback required Information are missing or feedback for suggestions is requested question A question about this library or its usage

Comments

@jeffreychuuu
Copy link

jeffreychuuu commented Sep 28, 2021

I'm using kotlin with spring boot building by gradle. The log shows that grpc server was listening on port 9090, while when I use BloobRpc to test if the server works, it reflects "error": "12 UNIMPLEMENTED: Method not found: demo.Greeter/SayHello".

My GrpcServerService basically is written by Java as below

@GrpcService
public class GrpcServerService extends GreeterGrpc.GreeterImplBase {
    @Override
    public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
        HelloReply reply = HelloReply.newBuilder().setMessage("Hello ==> " + req.getName()).build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}

Does anyone knows how to resolve this issue?

image

image

@jeffreychuuu jeffreychuuu added the question A question about this library or its usage label Sep 28, 2021
@jeffreychuuu jeffreychuuu changed the title Grpc server started but c Grpc server started but cannot connect Sep 28, 2021
@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 28, 2021

As you can see in the logs, the server did not find/register the grpc service.
Can you please check that the bean is actually created.

@ST-DDT ST-DDT added the feedback required Information are missing or feedback for suggestions is requested label Sep 28, 2021
@jeffreychuuu
Copy link
Author

The grpc server should have started correctly since once I changed the port to others in BloomRpc the error code is not "error": "12 UNIMPLEMENTED: Method not found: demo.Greeter/SayHello". It was "error": "14 UNAVAILABLE: failed to connect to all addresses" instead.

image

@jeffreychuuu
Copy link
Author

jeffreychuuu commented Sep 29, 2021

Would be appreciated that if you don't mind help me to check through my app. It locates at https://github.com/jeffreychu-org/kotlin_example_app in grpc-issue branch.

It may tested simply be

  1. cd /rdbms_service
  2. docker-compose up -d to start the PostgreSQL and redis
  3. simple start the spring boot app and it will trigger the other project grpc_lib to generate the grpc stub for use

This issue struggle me a few days. Many thanks. Cheers.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 29, 2021

$ docker compose up
(root) Additional property postgres is not allowed

I have trouble starting the docker compose on my computer (I haven't used it here before).
Maybe Windows doesn't like docker compose?

I still managed to start the application by stripping it of the other components.
FFR: Please reference only minimal workign examples not a project that showcases all.

2021-09-29 21:38:40.805  INFO 2888 --- [           main] n.d.b.g.s.s.AbstractGrpcServerFactory    : Registered gRPC service: grpc.health.v1.Health, bean: grpcHealthService, class: io.grpc.services.HealthServiceImpl
2021-09-29 21:38:40.805  INFO 2888 --- [           main] n.d.b.g.s.s.AbstractGrpcServerFactory    : Registered gRPC service: grpc.reflection.v1alpha.ServerReflection, bean: protoReflectionService, class: io.grpc.protobuf.services.ProtoReflectionService
2021-09-29 21:38:41.220  INFO 2888 --- [           main] n.d.b.g.s.s.GrpcServerLifecycle          : gRPC Server started, listening on address: *, port: 9090
2021-09-29 21:38:41.230  INFO 2888 --- [           main] c.e.k.KotlinExampleAppApplicationKt      : Started KotlinExampleAppApplicationKt in 3.566 seconds (JVM running for 4.106)

As you can see the server detected the two default grpc services ( ServerReflection, Health ).
But it didn't detect your GrpcServerService, nor did it execute its afterPropertiesSet method.
So the issue here is that the service doesn't get recognized as bean.
I tried to annotate it with @Component but doesn't seem to do the trick either.

I checked the jar and the class wasn't present there, so I suspect there is an issue with your build gradle that ignores plain java files.

@jeffreychuuu
Copy link
Author

jeffreychuuu commented Sep 30, 2021

Yes. That's what I'm also suspecting that if we can have hybird spring boot application with boot kotlin and java since I found that the bean is not created. Anyway, does this starter package support kotlin version? Since I know the message files generated by protoc are still java. Or is there any example of integrating with kotlin about this starter so I can get a try.

I'm wondering if this issue related.
image

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 30, 2021

Kotlin is definitely supported by this project.
https://github.com/yidongnan/grpc-spring-boot-starter/blob/master/docs/en/flavors.md
At this point you only have to add java support to your kotlin project.
Please refer to the official gradle/kotlin documentation or StackOverflow on how to do that.
Maybe all you have to do is adding the java library plugin.

@ST-DDT ST-DDT closed this as completed Sep 30, 2021
@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 30, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback required Information are missing or feedback for suggestions is requested question A question about this library or its usage
Projects
None yet
Development

No branches or pull requests

2 participants