PHP Websocket on Webserver
Asked Answered
S

2

6

A few days ago I setup this WebSocket server from http://code.google.com/p/phpwebsocket/

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.

I changed the the sockets connection to my domain but it didn`t work

Client.html:

var host = "ws://xxxxxxxx.com:12345/Websocket/server.php";

Server.php:

$master  = WebSocket("xxxxxx",12345);

I already tried it with different port(80,443,12345,8080,8000....), using the IP address in server.php instead of the domain.

I also used absolute and relative paths in the client.html.

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.

In the client.html it just shows:

WebSocket - status 0 Disconnected - status 3

My guess that the problem is that Strato is blocks me from using WebSockets. Is it possible to run WebSockets on my webspace?

Screak answered 8/12, 2012 at 13:49 Comment(11)
in the client windows it just shows me : WebSocket - status 0 Disconnected - status 3Screak
Did you consider using node.js and socket.io?Psychosexual
no I havent thought about that yet. If i cant get it work i need to switch anf give node.js maybe a tryScreak
And you're sure the client machine has the appropriate ports open too?Moneylender
yes, it did not make any differenceScreak
shouldn`t it work an port http ports 80, 443 anyway?Screak
Get a network analyzer and figure out what's really going on over the wire; find out where your PHP error log is and examine it for possible issues. Add anything you find to your question and we might be able to help, however the people you should check with are Strato.Wiseacre
Do some basic debugging. It's likely the php script.Pard
This question really lacks any useful information to help you debug further. You need turn up error reporting in PHP, gather information from your error logs about what's going on and check with your web hosting provider that they are not blocking the ports you're using and then come back with that information and update it here. There is no way anyone can help you debug that without any kind of useful error information or any of those basic steps of debugging.Kettledrum
Just checking - do you know that phpwebsocket only supports and old deprecated version of the websocket standard. You'll need a slightly old version of Safari or a pretty old version of Chrome to have any hope of connecting to itAlastair
but why does it work in Xampp then? I tested in the current version of Chrome and SafariScreak
P
4

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.

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.

Palladous answered 8/12, 2012 at 20:9 Comment(0)
S
3

Okay, to bring this to an end.

I found a solution to use my websockets app and I´ve got an explanation why it did not work on my shared hosting solution.

I contacted Strato who told me that they don`t allow Websocket on shared hosting. The only way to get a similiar result would be to use AJAX Long Pooling.

Now I purchased to a Virtual Server and my websocket app works great now.

Thanks for your support.

Screak answered 12/12, 2012 at 17:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.