本文主要是介绍SCRIPT12017: SCRIPT12017: WebSocket Error: SECURITY_ERR, Cross zone connection not allowed,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Internet Zones (MSIE and Edge)
Internet Explorer and Edge both disallow web socket connections between “internet zones” by default. In these cases, the following error messages will be logged in the console:
• Internet Explorer: “SCRIPT5022: SecurityError”
• Edge: “SCRIPT12017: WebSocket Error: SECURITY_ERR, Cross zone connection not allowed”
Here are 2 changes that helped me fix the issue and establish a localhost WebSocket connection.
- In the Control Panel - Internet Option, select the Security Tab. In the Security tab, select Local intranet zone. Click on Sites button and uncheck all checkboxes in Local intranet dialog. OR
- In the Control Panel - Internet Option, select the Security Tab. In the Security tab, select Local intranet zone. Click on Sites button and then on Advanced button in the Local intranet dialog, add the required web address to the same zone as localhost.
- 注意:第二个方法未起作用,最后使用的是第一个方法
原因是:浏览器安全限制不允许跨域访问
参考:
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/f0e96358-e832-45ea-8710-caa0e3801c92/websocket-error-on-microsoft-edge?forum=iewebdevelopment
https://stackoverflow.com/questions/47471024/websocket-on-loopback-cross-zone-connection-not-allowed-error-on-ms-edge
https://pisquare.osisoft.com/community/developers-club/restful-pi-system-access/blog/2018/6/4
这篇关于SCRIPT12017: SCRIPT12017: WebSocket Error: SECURITY_ERR, Cross zone connection not allowed的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!