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.51k stars 3.31k forks source link

Gateway don't close websocket connection when client close websocket. #845

Open xurui8691413 opened 5 years ago

xurui8691413 commented 5 years ago

Please run application and run GatewayTest can reproduce this problem ,and then run GatewayTest1 can close websocket connection because GatewayTest1 doesn't access through gateway. I think this issue is urgent that blocked us. Looking forward for your reply. spring-cloud-gateway-websocket-master.zip

sfk123 commented 5 years ago

I also have the same problem and look forward to repairing it as soon as possible.

maniek45 commented 5 years ago

I can confirm. I've also sent how to reproduce this issue in #480. It also blocking us.

ryanjbaxter commented 5 years ago

@xurui8691413 you sample needs some updating. First you should be using a release of Finchley and not a release candidate. Once you upgrade to Finchley.SR3 you need to correctly specify the URI in your route.

    @Bean
    public RouteLocator wsGateway(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("ws", predicate -> predicate
                        .path("/ws").filters(f ->f.setPath("/ws2"))
                        .uri("ws://localhost:8080"))
                .build();
    }

Specifying the path in the URI no longer works, you need to use the setPath filter.

After changing that I see the problem, but unsure of the fix here. @spencergibb any ideas? Could this be a reactor problem?

spencergibb commented 5 years ago

Related to Websocket ping #729

spencergibb commented 5 years ago

@rstoyanchev we need to have a chat about this and ping.

DevDengChao commented 5 years ago

Any solution comes out?

spencergibb commented 5 years ago

Not yet.

xurui8691413 commented 5 years ago

Not yet.

sorry to ask ,when will this issue can be fixed?

spencergibb commented 5 years ago

I have to speak with the spring team first.

maniek45 commented 5 years ago

any update on this issue?

yingziisme commented 5 years ago

any solution?

tinarooot commented 3 years ago

过去一年了,解决这个问题了吗? 我也遇到了

It's been a year, has this problem been solved? I also met

BhaveshLakhpati commented 2 years ago

In my case, the problem was the angular client. Please refer following snippet.

this.ws = new SockJS('http://localhost:8080/websocket-server'); this.stompClient = Stomp.over(this.ws); this.stompClient.disconnect();

{ ... "code": 1005, "reason": "" ... }

it seems disconnect() method terminates websocket connection abnormally which results in status code 1005. to overcome this, I used following approach.

this.ws = new WebSocket('http://localhost:8080/websocket-server'); this.stompClient = Stomp.over(this.ws);

this.stompClient.unsubscribe(); this.ws.close(1000);

inoublijamel commented 2 years ago

Any updates on this issue?