关于spirngboot后台接收wss协议问题

背景

前端websocket使用wss协议代码如下

this.websock = new WebSocket(`ws://xxxx:9092/blog/websocket/${this.currentUser.id}`)

nginx配置

clipboard.png

后台配置

@ServerEndpoint(value = "/websocket/{userId}")
@Component
public class BlogSocket {

问题描述

经过上面配置,浏览器报错 failed: Error during WebSocket handshake: Unexpected response code: 404

猜测

不知道后台那么配置能不能接受到nginx转发的http协议,可能问题出现在这。

请指点一下,万分感谢

阅读 4.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题