OneinStack下swoole的client执行失败

问答中心分类: PHPOneinStack下swoole的client执行失败
hongenhui asked 6 年 ago

OneinStack安装完成,swoole也安装完成,但是执行通过浏览器执行swoole的client,一直转圈。同样的代码通过其他方式安装php和swoole则可以。
请问是否有什么设置要开放,才可以。
 
server.php

$server = new swoole_server("127.0.0.1", 9502);
$server->set(array('task_worker_num' => 4));
$server->on('receive', function($server, $fd, $reactor_id, $data) {
$task_id = $server->task("Async");
echo "Dispath AsyncTask: [id=$task_id]\n";
});
$server->on('task', function ($server, $task_id, $reactor_id, $data) {
echo "New AsyncTask[id=$task_id]\n";
$server->finish("$data -> OK");
});
$server->on('finish', function ($server, $task_id, $data) {
echo "AsyncTask[$task_id] finished: {$data}\n";
});
$server->start();

client.php

$client = new swoole_client(SWOOLE_SOCK_TCP);
if ($client->connect('127.0.0.1', 9502)) {
$client->send("data");
} else {
echo "connect failed.";
}

2 Answers
oneinstack answered 6 年 ago
php和swoole版本是不是不兼容?默认swoole是使用最新的

hongenhui answered 6 年 ago
SWOOLE不支持apache的event模式, 支持prefork.