嗨,当我连接到用Java Spring Boot开发的Websocket服务器时,收到“无效的Sec-WebSocket-接受响应”错误。Java客户端能够成功连接并发送消息,
下面是我们的代码实现
导入StompClientLib
var socketClient = StompClientLib()
let completedWSURL = "ws://192.168.1.37:8080/iostest/chat"
let Request = NSMutableURLRequest(url: NSURL(string:completedWSURL)! as URL)
socketClient.openSocketWithURLRequest(request:Request, delegate: self as StompClientLibDelegate)
错误响应为 错误域= SRWebSocketErrorDomain代码= 2133“无效的Sec-WebSocket-接受响应” UserInfo = {NSLocalizedDescription =无效的Sec-WebSocket-接受响应}
非常感谢您的帮助。预先感谢。
答案 0 :(得分:0)
如果您使用的是SockJS,请使用后缀/websocket
示例:ws://192.168.1.37:8080/iostest/chat/websocket