php - 无法与位于 ws ://localhost:8000/socket/server/startDaemon. php 的服务器建立连接。 var socket = new WebSocket(主机);

标签 php html websocket phpwebsocket

我正在使用 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/

相关文章:

html - IE8+ 中输入元素的边框半径

javascript - .keydown() 当按下回车键时

html - 在复选框列表文本和复选框之间添加空格

node.js - nodejs 作为 websocket 客户端

php - 将配置数据发送到 websocket

php - 如何使用 phpquery 查找标签名称?

php - 如何使用 MIME 验证文件?

php - 无法从 JSON 文件获取正确的值到 MySQL 服务器

php - 使用 php 使用 sudo 执行命令

Golang websocket nil内存错误