错误“不是有效的 Socket 资源”实现 phpwebsocket 库
我正在尝试使用 phpwebsocket 库 http://code.google.com/p/phpwebsocket / 我正在使用 server.php 文件的 r8 版本。为了进行测试,我只是尝试使用也是由网站提供的 client.html 文件。
当服务器启动时,我得到以下信息:
Server Started : 2011-08-29 22:11:23
Master socket : Resource id #4
Listening on : www.midomain.com port 12345
但是当我在浏览器中加载 client.html 文件时,服务器显示以下错误:
Notice: Undefined variable: key1 in /home/mink500/public_html/test/server.php on line 143
Notice: Undefined variable: key2 in /home/mink500/public_html/test/server.php on line 143
Warning: socket_select(): 5 is not a valid Socket resource in /home/mink500/public_html/test/server.php on line 15
有两个变量未定义,并且函数 socket_select() 返回错误“5 is不是有效的套接字资源”
在浏览器中,加载文件后我会立即收到“已断开连接”消息。
我尝试使用 XAMPP(Apache 和 PHP)使服务器在本地工作,但出现了相同的错误。我还尝试更改端口并按照此问题中的说明进行操作:
http:// /code.google.com/p/phpwebsocket/issues/detail?id=33
但我仍然收到错误“5 不是有效的套接字资源”
我记得刷新页面几次我让它运行几个月前,但现在这是不可能的。此外,我需要它一直工作,而不是在我刷新页面 20 次之后才工作。
我还尝试使用 websocket.class.php 文件,但这次我在客户端收到错误。浏览器现在返回“WebSocket 握手期间出错:‘Sec-WebSocket-Accept’标头丢失”。
所以,我无法让它与旧文件或新文件、远程或本地服务器、魔术或显灵板一起工作!
有什么想法吗?
谢谢
I'm trying to work with the phpwebsocket library at http://code.google.com/p/phpwebsocket/
I'm using the version r8 of the server.php file. For testing I just tried with the client.html file, also provided by the website.
When the server is started I get this:
Server Started : 2011-08-29 22:11:23
Master socket : Resource id #4
Listening on : www.midomain.com port 12345
But when I load the client.html file in the browser, the server shows the following errors:
Notice: Undefined variable: key1 in /home/mink500/public_html/test/server.php on line 143
Notice: Undefined variable: key2 in /home/mink500/public_html/test/server.php on line 143
Warning: socket_select(): 5 is not a valid Socket resource in /home/mink500/public_html/test/server.php on line 15
There are two variables that are not defined, and the function socket_select() returns the error "5 is not a valid Socket resource"
In the browser I get the "Disconnected" message as soon as the file is loaded.
I tried to make the server work locally using XAMPP (Apache and PHP) but I got the same errors. I also tried to change ports and follow the instructions in this issue:
http://code.google.com/p/phpwebsocket/issues/detail?id=33
But I still get the error "5 is not a valid Socket resource"
I remember that refreshing the page several times I got it running a few months ago, but now it's impossible. Besides, I need it to work all the time, not just after I refresh the page like 20 times.
I also tried with the websocket.class.php file, but this time I get an error on the client side. The browser now returns "Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing".
So, I can't make it work with old or new files, with remote or local server, with magic or a ouija board!
Any idea?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从最新的 phpwebsocket client.html 和 server.php 文件开始,我用下面的代码替换了 getheaders() 和 dohandshake() 函数,这些代码在最新的 Chrome 中适用于我。然而,它目前不会写入浏览器,也不会在聊天框中发表一条用户评论后保持活动状态。
Starting with the newest phpwebsocket client.html and server.php files I replaced both the getheaders() and dohandshake() functions with the code below works for me in newest Chrome. However it currently does not write to the browser nor stay alive after one uer comment in the chat box.