spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.52k stars 3.32k forks source link

Does spring cloud gateway support load balance for netty server cluster ? #1862

Closed ryzencool closed 4 years ago

ryzencool commented 4 years ago

I hava websocket server cluster use netty, now i use springcloud gateway, i try to use lb:ws://ip:port , but it not work because of serviceIdList is empty. Can springcloud gateway support load balance for netty cluster by doing some configuration?

ryanjbaxter commented 4 years ago

You should not be using ip and port in the load balanced URL it needs to be a service id lb:ws://serviceid

ryzencool commented 4 years ago

Thanks for your answer, but my netty server is not registed on the springcloud registry like eureka, so it not has serviceId, how to solve it?

OlgaMaciaszek commented 4 years ago

In order to use load-balancing, you need to use a supported service-discovery based service resolution. If you do not use service registry, you can try the properties-based SimpleDiscoveryClient.

If you want to pass IP and PORT instead of using service Ids, you should not prefix the uri with lb: and just pass it directly, like in the code sample in this section.

Does this solve your issue?

ryzencool commented 4 years ago

Yes, Thank you very much. I refactor project by using springboot, and set spring.cloud.zookeeper.discovery.instance-port as my netty service port.