spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

Spring Cloud Gateway Fanout With multiple websocket services

Open unaccepted opened this issue 9 months ago • 0 comments

I have one websocket service that can be connected via ws://localhost:8080/poc/ws1.

I have created Spring coud gateway which is hosted in localhost:7070

When I use below conguration, I could able connect and send message to websocket service via api-gateway(ws://localhost:7070/poc/ws1)

cloud: gateway: routes: - id: ws1-route uri: ws://localhost:8080 predicates: - Path=/poc/ws1

Now I have a usecase where I have one more websocket service(ws2 hosted on localhost:8081) and I want to send the same message to this service also.

Limitation from client side is that I can not call api-gateway twice one for ws1 and other for ws2.

I tried to using below gateway routing config:

spring: application: name: gateway cloud: gateway: routes: - id: ws1-route uri: ws://localhost:8080 predicates: - Path=/poc/** filter: - RewritePath=/poc, /poc/ws1 - id: ws2-route uri: ws://localhost:8081 predicates: - Path=/poc/** filter: - RewritePath=/poc, /poc/ws2

But it doesn't seems to work. My expectation is when I make call to ws://localhost:7070/poc it should send message to both the ws channel.

unaccepted avatar Apr 09 '25 13:04 unaccepted