spring-cloud-gateway: spring gateway lost websocket close status code and reason
I use spring gateway as a proxy websocket.
I had a problem with closing a connection with a specific status code (for example - 4401). If I connect directly my custom codes and reasons come to the client. If I use spring gateway, the code and reason are lost.
I tried different options:
- Spring Boot 2.1.4 on client, gateway and server. Client receives:
CloseStatus[code=1000, reason=null] - Spring Boot 2.1.4 on gateway, server and com.neovisionaries:nv-websocket-client. Client receives:
WebSocketFrame(FIN=1,RSV1=0,RSV2=0,RSV3=0,Opcode=CLOSE,Length=0,CloseCode=1005,Reason=null)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Fixes gh-1057 — committed to dmkost/spring-cloud-gateway by dmkost 3 years ago
- Fix proxying websocket close status Fixes gh-1057 — committed to spring-cloud/spring-cloud-gateway by dmkost 3 years ago
Hi, any plan to fix the issue?
Hi @hamroune . I think the following steps will help you. You need to write own WebsocketRoutingFilter with fixes.
Hi, I’m have the same problem now. I guess no new solutions have been emerged…
Play is very simple.
Run the GatewayApplication Run the ServerApplication Run the ServerApplicationTests
test-gateway.zip
This issue can be reproduced quite easily.
var ws = new WebSocket('ws://localhost:8444/myws;ws.close(3000, "MY REASON");will log following:
2019-05-29 18:27:21.735 DEBUG 5096 --- [io-8443-exec-11] c.m.handler.MyWsHandler : [WS] Closing socket StandardWebSocketSession[id=e29c3fba-b5a9-9616-086a-56ac4cbd6b57, uri=ws://localhost:8444/myws] and status CloseStatus[code=3000, reason=MY REASON]var ws = new WebSocket('ws://localhost:8777/myws;and than close:ws.close(3000, "MY REASON");Hope that helps.