AsyncTcpConnection总是掉线的问题?

babyface201008

问题描述

用TP6的框架和workerman异步从第三方网站获取链接,但是,在启动几分钟后就会自动停掉,也没有调用onClose方法。

程序代码

gateway_worker配置
 // BusinsessWorker配置
    'businessWorker'        => [
        'name'         => 'BusinessWorker',
        'count'        => 1,
        'eventHandler' => '\app\push\controller\Events',
    ],

class Events extends PushController
{
    public static function onWorkerStart($worker)
    {
     // 异步建立一个连接
            $con = new AsyncTcpConnection(sysconfig('api', 'test_api'));
            $con->transport = 'ssl';
            $con->onConnect = function ($con) {
                Log::error('onConnect');
                \app\push\controller\Test::onAsyncConnect($con);
            };
            $con->onMessage = function ($con, $message) use($worker) {
                Log::error('onMessage');
                \app\push\controller\Test::onAsyncMessage($con, $message, $worker);
            };
            $con->onClose = function ($con) {
                // 如果连接断开,则在1秒后重连
                Log::error('reConnect');

                Timer::add(5, array($con, 'connect'), null, false);

                $con->reConnect(1);
            };
            $con->onError = function ($con, $code, $msg) {
                //错误的通知处理
                Log::error('error:'.$msg);
            };
            // 执行异步连接
            $con->connect();
     }
}

服务状态

截图
截图

操作系统及workerman/webman等框架组件具体版本

linux,TP6,workerman

719 1 0
1个回答

latin

debug方式运行看下报错,ffphp进程一直在退出,3个小时退出了12658次

年代过于久远,无法发表回答
×
🔝