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

Unable to integrate grpc with spring cloud gateway #3388

Closed
ShivaniSK opened this issue May 9, 2024 · 4 comments
Closed

Unable to integrate grpc with spring cloud gateway #3388

ShivaniSK opened this issue May 9, 2024 · 4 comments

Comments

@ShivaniSK
Copy link

I am trying to integrate grpc with spring cloud gateway.
I want to hit a grpc url 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'

Can you please help me out on the issue. Or let me know if have missed out on anything. Do i need to add any grpc specfic dependency?

@jivebreaddev
Copy link

jivebreaddev commented May 13, 2024

`Please try Spring Bean Configuration method to configure gateway for a fix for now.

yaml configuration to build a gateway seems to have an issue when binding the values.`

Sorry for the confusion I have made. I am working on the debugging to find the solution for it

Please ignore the answer I have given you.
Will get back to you once I found the reasons.

@ShivaniSK
Copy link
Author

ShivaniSK commented May 14, 2024

Hi @jivebreaddev ,
Sure thanks. Kindly let me know if its working fine for you or if anything missed from my side.

@ShivaniSK
Copy link
Author

Hi @jivebreaddev , is there any update ?

@ShivaniSK
Copy link
Author

Closing the ticket as raised another one with exact issue #3411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants