基于 webman + TP-ORM 的动态秒级定时任务管理 不能使用抛出异常

loveting

问题描述

查询定时任务列表报错,使用的是TP-ORM

程序代码

<?php
namespace app\common\task;
use yzh52521\Task\Client;

/**
 * 定时任务管理
 */
class Task{

    /**
     * 获取所有的任务列表
     */
    public static function list(int $page = 1, int $limit = 15)
    {
        return self::run('crontabIndex', ['limit' => $limit, 'page' => $page]);
    }

    /**
     * 执行命令
     */
    private static function run(string $method, array $args)
    {
        $param = [
            'method' => $method,//计划任务列表
            'args'   => $args//参数
        ];
        $result= Client::instance()->request($param);
        return json($result);
    }
}
?>

直接调用
 public function test_1()
 {
     $result = Task::list();
     return response($result);
 }

报错信息

ErrorException: stream_socket_client(): unable to connect to tcp://0.0.0.0:3650 (�����������У�������ĵ�ַ��Ч��
) in E:\ym_projects\ym_new_projects\control_center\vendor\yzh52521\webman-task\src\Client.php:14
Stack trace:
#0 [internal function]: support\App::{closure}(2, 'stream_socket_c...', 'E:\\ym_projects\\...', 14, Array)
#1 E:\ym_projects\ym_new_projects\control_center\vendor\yzh52521\webman-task\src\Client.php(14): stream_socket_client('tcp://0.0.0.0:3...')
#2 E:\ym_projects\ym_new_projects\control_center\vendor\yzh52521\webman-task\src\Client.php(20): yzh52521\Task\Client->__construct()
#3 E:\ym_projects\ym_new_projects\control_center\app\common\task\Task.php(27): yzh52521\Task\Client::instance()
#4 E:\ym_projects\ym_new_projects\control_center\app\common\task\Task.php(15): app\common\task\Task::run('crontabIndex', Array)
#5 E:\ym_projects\ym_new_projects\control_center\app\controller\Index.php(33): app\common\task\Task::list()
#6 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\webman-framework\src\App.php(284): app\controller\Index->test_1(Object(support\Request))
#7 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\webman-framework\src\App.php(122): Webman\App::Webman\{closure}(Object(support\Request))
#8 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\workerman\Connection\TcpConnection.php(638): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#9 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #149)
#10 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\workerman\Worker.php(2457): Workerman\Events\Select->loop()
#11 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\workerman\Worker.php(1443): Workerman\Worker->run()
#12 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\workerman\Worker.php(1386): Workerman\Worker::forkWorkersForWindows()
#13 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\workerman\Worker.php(559): Workerman\Worker::forkWorkers()
#14 E:\ym_projects\ym_new_projects\control_center\vendor\workerman\webman-framework\src\support\App.php(124): Workerman\Worker::runAll()
#15 E:\ym_projects\ym_new_projects\control_center\start.php(4): support\App::run()
#16 {main}

控制台信息

----------------------- WORKERMAN -----------------------------
Workerman version:4.1.3          PHP version:7.3.4
------------------------ WORKERS -------------------------------
worker                        listen                              processes status
webman                        http://0.0.0.0:8787                 2         [ok]
plugin.yzh52521.task.cron_tasktext://0.0.0.0:3650                 1         [ok]
monitor                       none                                1         [ok]
808 1 0
1个回答

six

unable to connect to tcp://0.0.0.0:3650
很明显,不应该连 tcp://0.0.0.0:3650,应该是连 tcp://127.0.0.1:3650。发起连接应该是确定的ip,而不是0.0.0.0

  • 暂无评论
年代过于久远,无法发表回答
×
🔝