无法与位于 ws://localhost:8000/socket/server/startDaemon.php 的服务器建立连接。 var socket = new WebSocket(主机);
我正在使用 javascript 连接 websocket:
<script>
var socket;
var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);
</script>
我收到错误:
无法与服务器建立连接
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);
I am using javascript to connect websocket:
<script>
var socket;
var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);
</script>
I got the error:
Can't establish a connection to the server at
var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);
How can I solve this issue?
NOTE : I enabled websocket in mozilla to support web socket application.
and when i run in chrome i got error:
can't establish a connection to the server at ws://localhost:8000/socket/server/startDaemon.php. var socket = new WebSocket(host);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
显然 Firefox 4 由于漏洞而禁用了 websocket。引用本文:
WebSocket 在 Firefox 4 中禁用
Apparently firefox 4 has websockets disabled because of vulnerabilities. To quote From this article:
WebSocket disabled in Firefox 4
我通过此链接跟踪代码
http:// www.flynsarmy.com/2010/05/php-web-socket-chat-application/
并为响应消息创建了 socketWebSocketTrigger.class.php 文件,其中代码为
,并在“WebSocketServer.php”的发送函数中添加了代码,用于调用“responseMessage”函数,该函数响应请求消息
效果很好。
I solved my error by following code through this link
http://www.flynsarmy.com/2010/05/php-web-socket-chat-application/
and created socketWebSocketTrigger.class.php file for response message where code as
and added code in send function of 'WebSocketServer.php' for calling 'responseMessage' function which response request message
it's working great.
您是否尝试在 Firefox 中运行客户端?根据文档:
尝试在 Chrome 中运行它,看看是否适合您。
Are you trying to run the client in Firefox? According to the documentation:
Try running it in Chrome and see if that works for you.
首先,您的错误是将 php 函数与 javascript
require_once 'WebSocket.php';
一起使用,然后按照下面的链接中的教程进行操作。http://net.tutsplus.com/tutorials/ javascript-ajax/start-using-html5-websockets-today/
工作正常。
谢谢,
First of all your mistake is using php function with javascript
require_once 'WebSocket.php';
and secondly go through the tutorial as in the link below.http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/
it's working fine.
Thanks,