1

I'm using a microservices architecture created via JHipster (Spring Boot, Zuul Proxy, Ribbon...). I have 2 microservices and a gateway (and of course a Registry).

I have a problem when sending HTTP errors from my microservices. The gateway seems to ignore the response from the microservice and generate a new response just using the error code.

Example :

My request generates a HTTP 404 in my microservice. If a request directly the microservice I have the following response body :

{
    "code": "DEVICE_NOT_FOUND",
    "message": "Gateway '12345678' unknown"
}

If I request the gateway (which transfer to the microservice), I now have the following body instead of the one generated by the service :

{
    "timestamp": "2016-08-11T12:50:57.432+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available"
}

The body from gateway does not contain any of the data from the licroservice error body...

If I understand, when the gateway get an error from a webcall, it calls a generated "/error" controller which create a response. I tried to implement my own /error controller by I was not able to get the original body. I also tried to add a @ControllerAdvice controller but no exception is returned in the gateway, it is just a redirect to the /error controller

Did I miss something ? Thanks in advance for your help.

1 Answers1

1

@GaëlMarziou OK I found how it works.

There is a Zuul filter (org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter) that catches microservice response body and call the ErrorController to generate its own one. I created my one Zuul filter (show the solution here) and overrided the whitelabel error controller (solution here) and I now have the response body of the microservice in my gateway.

Thanks for your help.

Community
  • 1
  • 1