首页 > websocket Firefox是成功的,但chrome会出下面错

websocket Firefox是成功的,但chrome会出下面错

ws://192.168.1.22:1234/,这里如果是ws的话,Firefox是成功的,但chrome会出下面错:

Mixed Content: The page at 'https://www.xxxx.com/xx' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://192.168.1.22:1234/'. This request has been blocked; this endpoint must be available over WSS.

Uncaught SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

如果改成了wss的话,Firefox直接报无法链接Abort,Chrome会出下面错:

WebSocket connection to 'wss://192.168.1.22:1234/' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

请教各位大神解答下~


你的网站是https的吗?
ws只能用在http下,https下得用wss,否则浏览器会说你这个是混合文档,拒绝在https下加载ws。
所以你必须使用wss协议。
而你wss协议需要在websocket服务端支持,你的这个服务端我估计不支持wss。

【热门文章】
【热门文章】