我正在使用 javascript 连接 websocket:
<script>
var socket;
var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);
</script>
我得到了错误:
Can't establish a connection to the server at
var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);
我该如何解决这个问题?
注意:我在 mozilla 中启用了 websocket 以支持 web 套接字应用程序。 当我在 chrome 中运行时出现错误:
can't establish a connection to the server at ws://localhost:8000/socket/server/startDaemon.php. var socket = new WebSocket(host);
最佳答案
显然 firefox 4 由于漏洞禁用了 websockets。引用这篇文章:
WebSocket disabled in Firefox 4
Recent discoveries found that the protocol that Websocket works with is vulnerable to attacks. Adam Barth demonstrated some serious attacks against the protocol that could be used by an attacker to poison caches that sit in between the browser and the Internet.
关于php - 无法与位于 ws ://localhost:8000/socket/server/startDaemon. php 的服务器建立连接。 var socket = new WebSocket(主机);,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6172364/