Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'http' is not allowed
时间: 2023-08-04 12:05:41 浏览: 271
回答: 当出现"Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. 'http' is not allowed"的错误时,这意味着在构建WebSocket对象时,URL的协议方案必须是'ws'或'wss',而不是'http'。\[1\]这个错误通常发生在尝试使用HTTP协议而不是WebSocket协议进行WebSocket连接时。WebSocket协议使用的是ws或wss协议方案,而不是http。\[3\]因此,要解决这个错误,你需要确保在构建WebSocket对象时使用正确的协议方案,即'ws'或'wss'。
#### 引用[.reference_title]
- *1* *2* [你还在使用 ajax 轮询吗?试试 WebSocket 让后端主动推送消息](https://blog.csdn.net/weixin_46784898/article/details/106440181)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [The WebSocket Protocol](https://blog.csdn.net/qiuchangyong/article/details/109633833)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文
相关推荐
















