php - Could not run socket server -


first thing, see out there has solved questions around problem.

php web socket unable bind socket

issue in setting socket server

socket_bind(): unable bind address [99] (ubuntu on amazon ec2)

and many other resources, of them said problem in-used port or external ip, etc.

but not on it. server running on centos 6.3 , using cpanel (it hp server https://www.hpcloud.com/).

the web socket demo source code on https://code.google.com/p/phpwebsocket/

my setting

$master  = websocket("127.0.0.1",4444); // tried localhost, worked same 

here step tried , corresponding errors:

1/. tried following commands ensure port using available use

$ lsof|grep 4444  $ netstat -a -p -n 

but got error although port 4444 free

warning: socket_bind(): unable bind address [98]: address in use in /home/myapp/public_html/websocket/server.php on line 60

2/. strange thing when checked port 835 using by

 crond      1621      root  del       reg              252,1               39835 /lib64/libpam.so.0.82.2.#prelink#.b1eygx  atd        1633      root  del       reg              252,1               39835 /lib64/libpam.so.0.82.2.#prelink#.b1eygx  

the funny thing happened:

then ran server.php on terminal command shell

 php /home/myapp/public_html/websocket/server.php 

the error has gone, instead of is

server started : 2013-08-16 03:19:54

master socket : resource id #4

listening on : 127.0.0.1 port 835

i thought started working, did not, because when open server.php browser url

http://mysite/server.php 

the error "permission denined"

warning: socket_bind() [function.socket-bind]: unable bind address [13]: permission denied in /home/myapp/public_html/websocket/server.php on line 60 socket_bind() failed

edited: permission, open client.html in same level directory server.php without problem. folder code permission 755 , user not root. of commands implemented under root privilege

any appreciated :(

i assume problem attempting load websocket server in webbrowser. likely, there security settings apache user not allow server listen on uncommon ports.

centos ships selinux enabled default. part of centos linux's security policies apache default, apache allow services access recognized ports associated http (ie, port 80, 8080 etc).

with selinux enabled, allow apache listen on tcp port 4444 adding rule allow inside selinux using 'semanage' command:

~$ semanage port -a -t http_port_t -p tcp 4444  

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -