workerman
workerman copied to clipboard
Bug with multi server - they start listen port and get connection by another
Example:
-
Start workerman Websocket server on port 8081 - all ok
-
Connect to server via another application (not workerman, client on local machine at c# language) - all ok
-
Start another workerman Websocket server on 8082 - all ok
-
Server point 1 (8081) create workerman AsyncTcpConnection to server from pint 3 (with port 8082) - all ok (doesnt matter wich server connect AsyncTcpConnection first)
-
Check after this 8081 port - not ok:
-
Master and Worker of server from point 3 (with 8082 port) start to listen 8081 port too (as Unix console say at the picture)
-
additional this server from point 3 (port 8082) start to listen my client (what connect only to 8081 server from point 1) (as Lunix console say - you can see t the picture)
- if i stop server from poit 1 (port 8081) server from point 3 still Listen the port 8081 and client from pint 2 now have Estabilished connection with server 3 (port 8082)
Without point 2 situatian is same (server 8082 start to listen 8081 too after 8082 get AsyncTcpConnection from 8081 or another side of AsyncTcpConnection will - same result )
Well the problem is when start two workerman servers and some one (doesnt matter who of they) will open AsyncTcpConnection to another - two servers will start to listen the port of server what start firstly
As i check it is happen when i try use "exec" as command to start one Werkerman from another Workerman
look like doesnt matter what i try execute from "exec" command from workerman - new process open and listen the port already (i try exec filу with "Hello World" code and process already in Unix termonal listen the port)
look like it is problem in php. After "stream_socket_server" (in Worker.php) if you will try "fork" or "exec" or "shell_exec" command to open new proccess - it will listen the port too .
But it not open another server - it still one. I was try fork and "unlisten" it in new process but it unlisen in both process :)
Any idea how start new server from current in new process ?
Is the event extension installed?
Is the event extension installed?
yes - Swoole. I try open create Timer with "exec" command to open new process with new workerman but result is same - new process will listen port too after it open (before eny code)
Workerman cannot change the features of PHP, such as the process inheritance listening socket when executing exec. As for the fork problem, some extensions do have such problems, for example, the event extension will affect the behavior of the other processes when you fork process and perform certain operations.
Workerman cannot change the features of PHP, such as the process inheritance listening socket when executing exec. As for the fork problem, some extensions do have such problems, for example, the event extension will affect the behavior of the other processes when you fork process and perform certain operations.
i see...Is it possible save connection after Worker reload if it reloadable? Because if PHP work so NEW worker process (what will fork from master) will have same socket connection as he have before
or maybe if save connections addres (ip and port) possible use stream_socket_client for get resource for new worker
PHP can not do that
PHP can not do that
but php already save the same socket at multi process, i think it is real...because then i disconnect from one process another still get connection of client (but client not connect exactly to this process, he connect to process what was close)
at this pictires - it is two different workerman master +1 worker have same client to connect o same socket
may be if master process can collect connections too (as worker do) and after reload worker fork byself with these connections...
i will create experiment
PHP can not do that
well it is 2 way but it possible
- use https://www.php.net/manual/en/function.socket-wsaprotocol-info-export.php but it only for windows
- use https://www.php.net/manual/en/class.ffi.php and find resource of socket in memory (as you can see it stiil alive at another process) but need write code in "C" language
Well for this reason i think i will use Gataway in my project :)
and normaly open another workerman from current workerman only via http , because as i say open via fork exec system shell - will get port's listening in another process - php work like this