Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've written a game using PHP web sockets that runs well on my local development server. I'm now attempting to run the web socket server on a non-local server, but my client JavaScript isn't able to connect. I'm attempting this on a clean install of Ubuntu Server x64 - I've installed apache2, php5, and made sure the PHP socket extention is enabled; the server is working great for non-web socket purposes.

Is there a configuration setting I'm missing? I've tried shutting down my firewall (via ufw disable). Any clues would be much appreciated.

EDIT

Here's the PHP library I'm using: https://github.com/Flynsarmy/PHPWebSocket-Chat

I've realized that I actually won't be needing apache for what I'm doing - I only need the incoming requests to be accepted and interpreted by PHP. Is there a way to ensure that all incoming requests are accessible to my PHP program?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Are you using apache module for websockets? There are quite a few PHP websocket servers implemented that you can try. Here are a few, http://www.spoutserver.com/ , http://code.google.com/p/phpwebsocket/ , http://socketo.me/ . There are a couple more if you look around. If youp provide more details on your environment and implementation, help is easier.

UPDATE:

Change line 62 from in https://github.com/Flynsarmy/PHPWebSocket-Chat/blob/master/server.php to

$Server->wsStartServer('0.0.0.0', 9300);

or the IP to your external LAN IP and it should work. Restart the server.php after the change.

share|improve this answer
    
Thanks for response - see my edit. –  Nathan Friend Aug 18 '12 at 3:37
    
Is this basic test working? -- github.com/Flynsarmy/PHPWebSocket-Chat/blob/master/README –  Chida Aug 18 '12 at 4:17
    
Just tried it out - yes, it is working, as long as I'm accessing it from the server (my client is connecting to 127.0.0.1:9300.) Now I just need to figure out how to allow PHP access to the incoming requests... –  Nathan Friend Aug 19 '12 at 19:46
    
Chida, you are my hero. –  Nathan Friend Aug 19 '12 at 20:11

As near as I can tell, the Apache packages provided by Ubuntu don't support websockets, and there is no package in Precise Pangolin that contains mod_websocket.so which is the Apache module that provides support for websockets. You'll need to install the module by hand, or change your production environment to use the same webserver as you're using in development.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.