Javascript WebSocket 连接到“ws://./”失败:连接建立错误:net::ERR_NAME_NOT_RESOLVED
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26542658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WebSocket connection to 'ws://./' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
提问by Sizzling Code
I dont have any knowledge in websockets, i am using a admin template from here
我对 websockets 一无所知,我正在使用这里的管理模板
https://github.com/onokumus/Bootstrap-Admin-Template
i don't know did i do something wrong or how it is giving this problem but i am getting this error in the google chrome Console.
我不知道我做错了什么或者它是如何产生这个问题的,但我在谷歌浏览器控制台中收到这个错误。
WebSocket connection to 'ws://./' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
it is reffering this file modernizr-build.min.js:2for error.
它正在引用此文件modernizr-build.min.js:2的错误。
Note:Error is only Showing in Google Chrome, but in Firebug this error is not showing up?
注意:错误仅在 Google Chrome 中显示,但在 Firebug 中未显示此错误?
Anyone Knows why i am getting this error and how to get rid of this error without compromising anything else in theme?

任何人都知道为什么我会收到此错误以及如何在不影响主题中的其他任何内容的情况下摆脱此错误?



回答by Aviator
It is because you have to use the FQDN for the WS URL. There is a good small sample code here: How to construct a WebSocket URI relative to the page URI?
这是因为您必须对 WS URL 使用 FQDN。这里有一个很好的小示例代码: 如何构造相对于页面 URI 的 WebSocket URI?

