Webserver上的PHP Websocket [英] PHP Websocket on Webserver
问题描述
几天前,我从 http://code.google.com/p设置此WebSocket服务器/ phpwebsocket /
使用Xampp在我的localhost上运行良好。然后,我将它上传到我在Strato上的网站空间,但现在我无法连接到服务器。
It works excellent on my localhost by using Xampp. Then, I uploaded it to my webspace on Strato, but now I am not able to connect to the server.
我将套接字连接更改为我的域但是它没有`t work
I changed the the sockets connection to my domain but it didn`t work
Client.html:
Client.html:
var host = "ws://xxxxxxxx.com:12345/Websocket/server.php";
Server.php:
Server.php:
$master = WebSocket("xxxxxx",12345);
我已经尝试过不同的端口(80,443,12345,8080,8000 ....),使用server.php中的IP地址而不是域。
I already tried it with different port(80,443,12345,8080,8000....), using the IP address in server.php instead of the domain.
我还在client.html中使用了绝对路径和相对路径。
I also used absolute and relative paths in the client.html.
从项目页面 http://code.google.com/p/phpwebsocket/ 有人建议在server.php中使用0或0.0.0.0,但这也不起作用。
From the projects page http://code.google.com/p/phpwebsocket/ someone suggested to use 0 or 0.0.0.0 in the server.php, but that didn`t work either.
在client.html中它只显示:
In the client.html it just shows:
WebSocket - 状态0
断开连接 - 状态3
WebSocket - status 0 Disconnected - status 3
我猜这个问题是那个Strato阻止我使用WebSockets。
是否可以在我的网站空间上运行WebSockets?
My guess that the problem is that Strato is blocks me from using WebSockets. Is it possible to run WebSockets on my webspace?
推荐答案
我的打赌是你的主机阻止传入的请求到插座。您不应该在Web服务中运行像phpwebsocket这样的脚本(它本身就是服务器)。这让很多人感到困惑,因为PHP通常用于脚本网页,而不是用于编码守护进程。
My bet is that your host is blocking incoming requests to the socket. Your not supposed to run scripts like phpwebsocket within a web service (it is a server itself). This confuses a lot of people since PHP is typically used for scripting webpages, not for coding daemons.
我这样说是因为你提到在Xampp中运行脚本,并提到您的托管服务为'webspace'。
I say this because you mentioned running the script within Xampp, and referred to your hosting service as 'webspace'.
如果是这种情况,您将不得不升级到虚拟服务器软件包,以便您可以运行自己的服务。
If this is the case you will have to upgrade to a virtual server package so that you can run your own services.
这篇关于Webserver上的PHP Websocket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!