grpc-spring icon indicating copy to clipboard operation
grpc-spring copied to clipboard

directly support grpc-web

Open mwelser opened this issue 6 years ago • 9 comments

it would be great to support grpc-web with an in-process proxy instead of using a real proxy in between the frontend and the backend to translate grpc-web->proxy->grpc-server. direct communication support instead would be a great feature

mwelser avatar Feb 22 '19 22:02 mwelser

I will have a look at this, but it might take some time.

ST-DDT avatar Feb 23 '19 17:02 ST-DDT

@mwelser I have a few questions regarding the implementation of this feature.

  • First of all, what do you expect to send to/receive from the server: JSON (any supported format by Spring) or Protobuf bytes?
    • I assume the former.
  • Which processing route do you expect the request to take:
    1. Web-Filter -> gRPC-Client -> gRPC-Server -> gRPC-Server-Interceptors -> gRPC-Service
    2. Web-Filter -> gRPC-Service
    • The main difference is that in the first case the request would take the usual gRPC processing route and would thus trigger the usual tracing, metrics and maybe gRPC authentication. However in that case it would be routed to both the web filters and the grpc interceptors, which might be confusing especially for security related stuff. I would recommend the second option.
  • How should streaming calls be handled?
    • With lists of input/output data?

ST-DDT avatar Mar 03 '19 01:03 ST-DDT

@mwelser I started the implementation in #207 . The PR is WIP, but it should be functional at least for simple use cases. Any feedback would be appreciated.

It is not likely that the feature will make it into the upcoming release 2.3.0 though.

ST-DDT avatar Apr 03 '19 16:04 ST-DDT

Server enabled Security, configure SSL why prompt “Security is enabled but this implementation does not support Security! ”?

Jarvis8099 avatar Jan 17 '20 10:01 Jarvis8099

See also: https://mvnrepository.com/artifact/io.grpc/grpc-servlet

ST-DDT avatar Mar 09 '23 08:03 ST-DDT

Hi. I want to implement in-process proxy for grpc-web, but I can't figure out how to. Can you provide more information?

wirekang avatar May 18 '23 06:05 wirekang

I'm not sure what exactly you are asking for.

  • Web-Request -> grpc-servlet -> @GrpcService
  • or Web-Request -> RestController -> InProcessChannel -> InProcessServer -> @GrpcService

ST-DDT avatar May 18 '23 11:05 ST-DDT

I'm trying first way. How can I use grpc-servlet with grpc-spring-boot-starter? Despite it neglected for 3 years, does GrpcServlet works well? GrpcServlet requires all services and their urlPatterns. Should I pass all my service information manually? Is there a way to use netty instead of servlet using NettyServerBuilder?

wirekang avatar May 19 '23 03:05 wirekang

Despite it neglected for 3 years, does GrpcServlet works well?

AFAICT it was only added this year?

https://github.com/grpc/grpc-java/commits/master/servlet

GrpcServlet requires all services and their urlPatterns.

I dont see a way to configure urls:

https://github.com/grpc/grpc-java/blob/478f30e6458a72957106b44657608b9cd4ee6c1b/servlet/src/main/java/io/grpc/servlet/GrpcServlet.java#L53

Should I pass all my service information manually?

As for finding all your services you can leave that to the https://github.com/yidongnan/grpc-spring-boot-starter/blob/72159342ca2001a596cf32b4eb456478156eefbb/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/service/GrpcServiceDiscoverer.java#L32 bean.

Is there a way to use netty instead of servlet using NettyServerBuilder?

Not via Netty Server Builder Afaict but with whatever means this code uses: https://github.com/grpc/grpc-java/blob/478f30e6458a72957106b44657608b9cd4ee6c1b/servlet/src/main/java/io/grpc/servlet/ServletServerBuilder.java#L100

Not sure if that actually starts a server or only the adapter. You might need a netty servlet dependency as well.

ST-DDT avatar May 19 '23 08:05 ST-DDT