Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【WebSocket】在服务端主动断开连接的时候,如何通知客户端原因 #675

Open
KarlSWJLU opened this issue Jan 22, 2025 · 1 comment

Comments

@KarlSWJLU
Copy link

我尝试在Server端使用WebSocektChannel的close()方法主动关闭连接,但这个方法没有其他参数,所以我如何通知客户端连接关闭的原因?

@KarlSWJLU KarlSWJLU changed the title 在服务端主动断开连接的时候,如何通知客户端原因 【WebSocket】在服务端主动断开连接的时候,如何通知客户端原因 Jan 22, 2025
@ithewei
Copy link
Owner

ithewei commented Jan 22, 2025

你是想使用ws协议的CLOSE类型帧带上原因吧,可以使用ws.send(reason, WS_OPCODE_CLOSE)后再调用close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants