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.";
}