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.

  1. 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
  2. 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. 
  3. 注意:第二个方法未起作用,最后使用的是第一个方法

原因是:浏览器安全限制不允许跨域访问

参考:

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

发布了21 篇原创文章 · 获赞 16 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/thlzjfefe/article/details/105273514