寶塔 和 docker
php 版本 7.4 和 8.0
在 windows 本機(jī)上啟動(dòng)時(shí) php7.4 和 8.0 均正常的,web-msg-sender 9191 端口可正常啟動(dòng),連接
但是在linux 和 docker 容器中均不能啟動(dòng),
在啟動(dòng)了之后,查看端口,9191 端口是被啟動(dòng)了的,但是命令行中一直在報(bào)錯(cuò)
$io = new SocketIO($port, $context);
$io->worker->name = 'SheepChatWorker';
$io->worker->count = $worker_num; // 啟動(dòng) worker 的進(jìn)程數(shù)量;
$io->debug = $debug; // 自定義 debug
// 定義命名空間
$nsp = $io->of('/chat');
$io->on('workerStart', function () use ($io, $nsp, $inside_port) {
$inner_http_worker = new Worker('http://0.0.0.0:' . $inside_port);
$inner_http_worker->onMessage = function (TcpConnection $httpConnection, Request $request) use ($io, $nsp) {
// 請求地址
$uri = $request->uri();
// 請求參數(shù)
$data = $request->post();
$chat = new Chat($io, $nsp);
$chat->innerWorker($httpConnection, $uri, $data);
};
$inner_http_worker->listen();
});
報(bào)錯(cuò)提示端口被占用,但是確認(rèn) linux 和 docker 中都沒有進(jìn)程使用 9191端口
Address already in use 這個(gè)錯(cuò)誤是一直在重復(fù)的報(bào)錯(cuò),這里只截取了一個(gè)完整的錯(cuò)誤信息
$ sudo -u www /www/server/php/74/bin/php think sheep:chat // 自己寫的 thinkphp command
Workerman[think sheep:chat] start in DEBUG mode
-------------------------------------------- WORKERMAN ---------------------------------------------
Workerman version:4.0.19 PHP version:7.4.9
--------------------------------------------- WORKERS ----------------------------------------------
proto user worker listen processes status
tcp www SheepChatWorker socketIO://0.0.0.0:2121 2 [OK]
----------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
think\exception\ErrorException: stream_socket_server(): unable to connect to tcp://0.0.0.0:9191 (Address already in use) in /www/wwwroot/sa.test.7wpp.com/vendor/workerman/workerman/Worker.php:2255
Stack trace:
#0 [internal function]: think\initializer\Error->appError()
#1 /www/wwwroot/sa.test.7wpp.com/vendor/workerman/workerman/Worker.php(2255): stream_socket_server()
#2 /www/wwwroot/sa.test.7wpp.com/app/sheep/console/SheepChat.php(114): Workerman\Worker->listen()
#3 /www/wwwroot/sa.test.7wpp.com/vendor/workerman/workerman/Worker.php(2415): app\sheep\console\SheepChat->app\sheep\console\{closure}()
#4 /www/wwwroot/sa.test.7wpp.com/vendor/workerman/workerman/Worker.php(1554): Workerman\Worker->run()
#5 /www/wwwroot/sa.test.7wpp.com/vendor/workerman/workerman/Worker.php(1384): Workerman\Worker::forkOneWorkerForLinux()
#6 /www/wwwroot/sa.test.7wpp.com/vendor/workerman/workerman/Worker.php(1358): Workerman\Worker::forkWorkersForLinux()
#7 /www/wwwroot/sa.test.7wpp.com/vendor/workerman/workerman/Worker.php(542): Workerman\Worker::forkWorkers()
#8 /www/wwwroot/sa.test.7wpp.com/app/sheep/console/SheepChat.php(162): Workerman\Worker::runAll()
#9 /www/wwwroot/sa.test.7wpp.com/app/sheep/console/SheepChat.php(66): app\sheep\console\SheepChat->start()
#10 /www/wwwroot/sa.test.7wpp.com/vendor/topthink/framework/src/think/console/Command.php(210): app\sheep\console\SheepChat->execute()
#11 /www/wwwroot/sa.test.7wpp.com/vendor/topthink/framework/src/think/Console.php(655): think\console\Command->run()
#12 /www/wwwroot/sa.test.7wpp.com/vendor/topthink/framework/src/think/Console.php(314): think\Console->doRunCommand()
#13 /www/wwwroot/sa.test.7wpp.com/vendor/topthink/framework/src/think/Console.php(251): think\Console->doRun()
#14 /www/wwwroot/sa.test.7wpp.com/think(16): think\Console->run()
#15 {main}
Worker[7857] process terminated
worker[SheepChatWorker:7857] exit with status 64000
目前沒有解決思路,請大佬指點(diǎn)一二,拜謝