I am trying to integrate grpc with spring cloud gateway.
I want to hit a grpc gateway url with proto file and redirect it to the grpc service.
My gateway config looks like below
...
..
..
server:
port: 8080
http2:
enabled: true
spring:
application:
name: API Gateway
main:
banner-mode: "off"
web-environment: false
web-application-type: reactive
allow-bean-definition-overriding: true
allow-circular-references: true
cloud:
gateway:
filter:
remove-hop-by-hop:
headers:
- connection
- keep-alive
- transfer-encoding
- proxy-authenticate
- proxy-authorization
- x-application-context
- upgrade
httpclient:
wiretrap: true
ssl:
use-insecure-trust-manager: true
httpserver:
wiretrap: true
routes:
- id: grpc-test
uri: ${service_grpc_url:grpc://grpc-test:50053}
predicates:
- Path= /grpc-api/**
filters:
- RewritePath=/grpc-api(?<segment>/?.*), ${segment}
..
..
..
On deploying above changes, when i hit the below gateway url
grpc://<api-gateway-host>:8080/grpc-api
It does not redirect to grpc://grpc-test:50053
. I get “service unavailable error“.
I am able to reach the grpc service pod directly by hitting grpc://grpc-test:50053, but its not redirecting via api-gateway.
I am using springboot version 3.2.3.
Spring cloud version is 2023.0.0.
I have added below dependencies
implementation (group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client')
implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-security')
implementation (group: 'org.springframework.boot', name: 'spring-boot-starter-web')
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-openfeign-core'
Not sure if have missed out on anything. Do I need to add any grpc specific dependency?