1.前端连接的时候传递在请求地址上面加上?userId="558888" 2.创建一个继承IUserIdProvider的类 3.在Program.cs种添加一个Serveice 项目源码地址:github.com/cplmlm/WebSocketService