Dual-system hot backup, how to use floating IP to access remote services across the network

The environment is as follows:
There are two servers A and B locally
A: 192.168.151.170 (main)
B: 192.168.151.171 (standby)
Floating IP of the two machines: 192.168.151.174
Bearer network IP: 10.182.254.164 Remote
server: 172.16 .122.39

is the IP of the A server mapped by the bearer network before installing the dual server. Server A can ping and telnet remote servers. For example: ping 172.16.122.39. The code for calling the remote server interface in the code is as follows:
String wsdlUrl = "http://172.16.122.39:8080/interface4wcp/wcpActionServlet";
URL url = new URL(wsdlUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

After the dual server is installed, the floating IP of the bearer network mapping. Which server the application floats to, the server can only ping the remote server through the source address. For example: ping -I 192.168.151.174 172.16.122.39. The plumber said it was normal. What needs to be modified is that when calling the remote server interface in the code, it also needs to be converted to the source address before calling.
Will the heroes, how to write the code? How to convert the source address first and then call the interface of the remote server?

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987592&siteId=291194637