简体   繁体   中英

WebClient (spring-boot-starter-webflux) sends request to incorrect url

I have two small apps, a client and a service.

Service is using -> http://dev.security.api.com:8080/api/

Client is using -> http://dev.security.com/

Using WebClient from “spring-boot-starter-webflux”, I faced the following issue.

Connection refused: dev.security.api.com/127.0.0.1:8080

I am unable to understand why it is using a different url.

The code is:

WebClient client2 = WebClient.builder()
        .baseUrl("http://dev.security.api.com:8080/api")
        .build();

I am using docker and they are running in two different containers.

Running the applications individually work fine, but when I am trying to send a request from client to the service. I am getting the error above.

Any ideas?

I think the error is at the ports

How to debug it:

  1. Create a test curl request
  2. Call it from the same environment (docker container)
  3. If error then check active open ports
  4. When curl is okay - implement it inside Java code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM