如果服务端没有使用SSL,使用WebSocket
1 | websocket = new WebSocket("ws://域名/path"); |
如果服务端使用SSL,使用WebSocket
1 | websocket = new WebSocket("wss://域名/path"); |
可以理解wss高级了一些,否则会报错误
1 | Error during WebSocket handshake: Unexpected response code: 301 |
或1
Error during WebSocket handshake: Unexpected response code: 302