My microservice is required to direct requests between 2 different servers via TCP connection. Using the current TCPClient, we are required to provide the host & port numbers which means that I can connect to one server
TcpClient.create().host(host).port(port)
I did see that netflix ribbon can support tcp but most examples are related to http & eureka
I tried using netflix ribbon where i define the ip address and port number under listOfServers in configuration, and annotate tcpClient bean as load balanced. This does not work. Is there any other solution for client side load balancing or should we create multiple tcp clients and rotate the requests between the different tcp clients?
@Bean
@LoadBalanced
public TcpClient customTcpClient(){
return TcpClient.create();
}
SERVICE:
ribbon:
listOfServers: 123456:1500, 223456:1500
Error: Connection refused. No further information
Note: in the original implementation, it is created with host & port, and then autowired into another class to send request and receive response
EDIT: Based on this discussion, is it right to say that only RestTemplate has support for @LoadBalanced and as such my implementation will not work? https://stackoverflow.com/questions/39587317/difference-between-ribbonclient-and-loadbalanced#:~:text=TL%3BDR%3A%20%40LoadBalanced%20is,is%20used%20for%20configuration%20purposes.