dockeropenfeign

Feign.Builder "target values must be absolute" error: how to call docker container with absolute url?


I have several microservices communicating each other with OpenFeign. Each one is a submodule of a project(call it "parent"), with its own docker container.

OK. So, when I want to build a client with feign.builder().target() method, an error occurs claiming that "target values must be absolute". I checked the source code, and it means (feign.RequestTemplate.target(RequestTemplate.java:447)):

  public static boolean isAbsolute(String uri) {
    return uri != null && !uri.isEmpty() && uri.startsWith("http");
  }

Here comes the question: the url of other services are like:

another-service:8080/check

In local tests, this is not a problem, because the profile local has http://localhost:8080 and so on. But in an end-to-end test this cannot bypass the absolute check.

So, what to do now?


Solution

  • I just added http:// before the service name and this is fixed.

    Looks like when creating containers needing to communicate with each other, docker does two things:

    Note that I used inner ports, not "outer" ports. For example, if service-A has ports config like:

    ports:
      - "8083:8080"
    

    Inside the network(curl from other containers) we use 8080, but from "outside"(from host, using Postman) we use 8083.

    PS:

    I used uname -a to check the dist of container is Debian and then I apt update && apt install curl to install curl executable.